Patchwork [STABLE] cmdutil: warnings not issued in cat if subrepopath overlaps

login
register
mail settings
Submitter Hannes Oldenburg
Date July 27, 2016, 8:56 a.m.
Message ID <1cb0ce20c615d848b7ca.1469609802@localhost.localdomain>
Download mbox | patch
Permalink /patch/15988/
State Accepted
Headers show

Comments

Hannes Oldenburg - July 27, 2016, 8:56 a.m.
# HG changeset patch
# User Hannes Oldenburg <hannes.christian.oldenburg@gmail.com>
# Date 1469608734 0
#      Wed Jul 27 08:38:54 2016 +0000
# Branch stable
# Node ID 1cb0ce20c615d848b7ca50fb23096cdc27d4b6d1
# Parent  6217180f9ab8c61320ea3826591960415779282e
cmdutil: warnings not issued in cat if subrepopath overlaps

Previously a subrepository "sub" would cause no warnings to
be issued for a file "subnot/a", if it's not present in the
corresponding changeset when calling:

hg cat subnot/a
Augie Fackler - July 27, 2016, 1:16 p.m.
On Wed, Jul 27, 2016 at 08:56:42AM +0000, Hannes Oldenburg wrote:
> # HG changeset patch
> # User Hannes Oldenburg <hannes.christian.oldenburg@gmail.com>
> # Date 1469608734 0
> #      Wed Jul 27 08:38:54 2016 +0000
> # Branch stable
> # Node ID 1cb0ce20c615d848b7ca50fb23096cdc27d4b6d1
> # Parent  6217180f9ab8c61320ea3826591960415779282e
> cmdutil: warnings not issued in cat if subrepopath overlaps

Queued, thanks.

>
> Previously a subrepository "sub" would cause no warnings to
> be issued for a file "subnot/a", if it's not present in the
> corresponding changeset when calling:
>
> hg cat subnot/a
>
> diff -r 6217180f9ab8 -r 1cb0ce20c615 mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py	Mon Jul 25 12:59:52 2016 +0800
> +++ b/mercurial/cmdutil.py	Wed Jul 27 08:38:54 2016 +0000
> @@ -2584,7 +2584,7 @@
>      # Don't warn about "missing" files that are really in subrepos
>      def badfn(path, msg):
>          for subpath in ctx.substate:
> -            if path.startswith(subpath):
> +            if path.startswith(subpath + '/'):
>                  return
>          matcher.bad(path, msg)
>
> diff -r 6217180f9ab8 -r 1cb0ce20c615 tests/test-subrepo.t
> --- a/tests/test-subrepo.t	Mon Jul 25 12:59:52 2016 +0800
> +++ b/tests/test-subrepo.t	Wed Jul 27 08:38:54 2016 +0000
> @@ -60,6 +60,9 @@
>    $ hg remove -S snot/file
>    not removing snot/file: file is untracked
>    [1]
> +  $ hg cat snot/filenot
> +  snot/filenot: no such file in rev 7cf8cfea66e4
> +  [1]
>    $ rm -r snot
>
>  Revert subrepo and test subrepo fileset keyword:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Jun Wu - July 27, 2016, 1:38 p.m.
Excerpts from Hannes Oldenburg's message of 2016-07-27 08:56:42 +0000:
> # HG changeset patch
> # User Hannes Oldenburg <hannes.christian.oldenburg@gmail.com>
> # Date 1469608734 0
> #      Wed Jul 27 08:38:54 2016 +0000
> # Branch stable
> # Node ID 1cb0ce20c615d848b7ca50fb23096cdc27d4b6d1
> # Parent  6217180f9ab8c61320ea3826591960415779282e
> cmdutil: warnings not issued in cat if subrepopath overlaps
> 
> Previously a subrepository "sub" would cause no warnings to
> be issued for a file "subnot/a", if it's not present in the
> corresponding changeset when calling:
> 
> hg cat subnot/a
> 
> diff -r 6217180f9ab8 -r 1cb0ce20c615 mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py    Mon Jul 25 12:59:52 2016 +0800
> +++ b/mercurial/cmdutil.py    Wed Jul 27 08:38:54 2016 +0000
> @@ -2584,7 +2584,7 @@
>      # Don't warn about "missing" files that are really in subrepos
>      def badfn(path, msg):
>          for subpath in ctx.substate:
> -            if path.startswith(subpath):
> +            if path.startswith(subpath + '/'):

Should we use os.path.sep here?

>                  return
>          matcher.bad(path, msg)
>  
> diff -r 6217180f9ab8 -r 1cb0ce20c615 tests/test-subrepo.t
> --- a/tests/test-subrepo.t    Mon Jul 25 12:59:52 2016 +0800
> +++ b/tests/test-subrepo.t    Wed Jul 27 08:38:54 2016 +0000
> @@ -60,6 +60,9 @@
>    $ hg remove -S snot/file
>    not removing snot/file: file is untracked
>    [1]
> +  $ hg cat snot/filenot
> +  snot/filenot: no such file in rev 7cf8cfea66e4
> +  [1]
>    $ rm -r snot
>  
>  Revert subrepo and test subrepo fileset keyword:
Yuya Nishihara - July 27, 2016, 3:20 p.m.
On Wed, 27 Jul 2016 14:38:39 +0100, Jun Wu wrote:
> Excerpts from Hannes Oldenburg's message of 2016-07-27 08:56:42 +0000:
> > # HG changeset patch
> > # User Hannes Oldenburg <hannes.christian.oldenburg@gmail.com>
> > # Date 1469608734 0
> > #      Wed Jul 27 08:38:54 2016 +0000
> > # Branch stable
> > # Node ID 1cb0ce20c615d848b7ca50fb23096cdc27d4b6d1
> > # Parent  6217180f9ab8c61320ea3826591960415779282e
> > cmdutil: warnings not issued in cat if subrepopath overlaps
> > 
> > Previously a subrepository "sub" would cause no warnings to
> > be issued for a file "subnot/a", if it's not present in the
> > corresponding changeset when calling:
> > 
> > hg cat subnot/a
> > 
> > diff -r 6217180f9ab8 -r 1cb0ce20c615 mercurial/cmdutil.py
> > --- a/mercurial/cmdutil.py    Mon Jul 25 12:59:52 2016 +0800
> > +++ b/mercurial/cmdutil.py    Wed Jul 27 08:38:54 2016 +0000
> > @@ -2584,7 +2584,7 @@
> >      # Don't warn about "missing" files that are really in subrepos
> >      def badfn(path, msg):
> >          for subpath in ctx.substate:
> > -            if path.startswith(subpath):
> > +            if path.startswith(subpath + '/'):
> 
> Should we use os.path.sep here?

A path here appears to be normalized. If not, using subpath would be wrong
anyway.
Hannes Oldenburg - July 27, 2016, 3:23 p.m.
I was wondering too, but since literal slashes it those checks are in more
places, i figured either i'm missing something,
or it's better done in other patches.

On Wed, Jul 27, 2016 at 1:38 PM, Jun Wu <quark@fb.com> wrote:

>
> Excerpts from Hannes Oldenburg's message of 2016-07-27 08:56:42 +0000:
> > # HG changeset patch
> > # User Hannes Oldenburg <hannes.christian.oldenburg@gmail.com>
> > # Date 1469608734 0
> > #      Wed Jul 27 08:38:54 2016 +0000
> > # Branch stable
> > # Node ID 1cb0ce20c615d848b7ca50fb23096cdc27d4b6d1
> > # Parent  6217180f9ab8c61320ea3826591960415779282e
> > cmdutil: warnings not issued in cat if subrepopath overlaps
> >
> > Previously a subrepository "sub" would cause no warnings to
> > be issued for a file "subnot/a", if it's not present in the
> > corresponding changeset when calling:
> >
> > hg cat subnot/a
> >
> > diff -r 6217180f9ab8 -r 1cb0ce20c615 mercurial/cmdutil.py
> > --- a/mercurial/cmdutil.py    Mon Jul 25 12:59:52 2016 +0800
> > +++ b/mercurial/cmdutil.py    Wed Jul 27 08:38:54 2016 +0000
> > @@ -2584,7 +2584,7 @@
> >      # Don't warn about "missing" files that are really in subrepos
> >      def badfn(path, msg):
> >          for subpath in ctx.substate:
> > -            if path.startswith(subpath):
> > +            if path.startswith(subpath + '/'):
>
> Should we use os.path.sep here?
>
> >                  return
> >          matcher.bad(path, msg)
> >
> > diff -r 6217180f9ab8 -r 1cb0ce20c615 tests/test-subrepo.t
> > --- a/tests/test-subrepo.t    Mon Jul 25 12:59:52 2016 +0800
> > +++ b/tests/test-subrepo.t    Wed Jul 27 08:38:54 2016 +0000
> > @@ -60,6 +60,9 @@
> >    $ hg remove -S snot/file
> >    not removing snot/file: file is untracked
> >    [1]
> > +  $ hg cat snot/filenot
> > +  snot/filenot: no such file in rev 7cf8cfea66e4
> > +  [1]
> >    $ rm -r snot
> >
> >  Revert subrepo and test subrepo fileset keyword:
>
Augie Fackler - July 27, 2016, 6:39 p.m.
On Wed, Jul 27, 2016 at 02:38:39PM +0100, Jun Wu wrote:
>
> Excerpts from Hannes Oldenburg's message of 2016-07-27 08:56:42 +0000:
> > # HG changeset patch
> > # User Hannes Oldenburg <hannes.christian.oldenburg@gmail.com>
> > # Date 1469608734 0
> > #      Wed Jul 27 08:38:54 2016 +0000
> > # Branch stable
> > # Node ID 1cb0ce20c615d848b7ca50fb23096cdc27d4b6d1
> > # Parent  6217180f9ab8c61320ea3826591960415779282e
> > cmdutil: warnings not issued in cat if subrepopath overlaps
> >
> > Previously a subrepository "sub" would cause no warnings to
> > be issued for a file "subnot/a", if it's not present in the
> > corresponding changeset when calling:
> >
> > hg cat subnot/a
> >
> > diff -r 6217180f9ab8 -r 1cb0ce20c615 mercurial/cmdutil.py
> > --- a/mercurial/cmdutil.py    Mon Jul 25 12:59:52 2016 +0800
> > +++ b/mercurial/cmdutil.py    Wed Jul 27 08:38:54 2016 +0000
> > @@ -2584,7 +2584,7 @@
> >      # Don't warn about "missing" files that are really in subrepos
> >      def badfn(path, msg):
> >          for subpath in ctx.substate:
> > -            if path.startswith(subpath):
> > +            if path.startswith(subpath + '/'):
>
> Should we use os.path.sep here?

This is at the ctx level, so I think '/' is correct (since we're still purely internal).

>
> >                  return
> >          matcher.bad(path, msg)
> >
> > diff -r 6217180f9ab8 -r 1cb0ce20c615 tests/test-subrepo.t
> > --- a/tests/test-subrepo.t    Mon Jul 25 12:59:52 2016 +0800
> > +++ b/tests/test-subrepo.t    Wed Jul 27 08:38:54 2016 +0000
> > @@ -60,6 +60,9 @@
> >    $ hg remove -S snot/file
> >    not removing snot/file: file is untracked
> >    [1]
> > +  $ hg cat snot/filenot
> > +  snot/filenot: no such file in rev 7cf8cfea66e4
> > +  [1]
> >    $ rm -r snot
> >
> >  Revert subrepo and test subrepo fileset keyword:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff -r 6217180f9ab8 -r 1cb0ce20c615 mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Mon Jul 25 12:59:52 2016 +0800
+++ b/mercurial/cmdutil.py	Wed Jul 27 08:38:54 2016 +0000
@@ -2584,7 +2584,7 @@ 
     # Don't warn about "missing" files that are really in subrepos
     def badfn(path, msg):
         for subpath in ctx.substate:
-            if path.startswith(subpath):
+            if path.startswith(subpath + '/'):
                 return
         matcher.bad(path, msg)
 
diff -r 6217180f9ab8 -r 1cb0ce20c615 tests/test-subrepo.t
--- a/tests/test-subrepo.t	Mon Jul 25 12:59:52 2016 +0800
+++ b/tests/test-subrepo.t	Wed Jul 27 08:38:54 2016 +0000
@@ -60,6 +60,9 @@ 
   $ hg remove -S snot/file
   not removing snot/file: file is untracked
   [1]
+  $ hg cat snot/filenot
+  snot/filenot: no such file in rev 7cf8cfea66e4
+  [1]
   $ rm -r snot
 
 Revert subrepo and test subrepo fileset keyword: