Patchwork [stable] cmdutil: warnings not issued in remove if subrepopath overlaps

login
register
mail settings
Submitter Hannes Oldenburg
Date July 22, 2016, 11:36 a.m.
Message ID <8549f914ebc264422487.1469187383@localhost.localdomain>
Download mbox | patch
Permalink /patch/15970/
State Superseded
Delegated to: Yuya Nishihara
Headers show

Comments

Hannes Oldenburg - July 22, 2016, 11:36 a.m.
# HG changeset patch
# User Hannes Oldenburg hannes.christian.oldenburg@gmail.com
# Date 1469186982 0
#      Fri Jul 22 11:29:42 2016 +0000
# Branch stable
# Node ID 8549f914ebc26442248701789a45feda94d979d7
# Parent  d3df009ab1175a6792549b51ae66486dd98f398b
cmdutil: warnings not issued in remove if subrepopath overlaps

Previously a subrepository "sub" would cause no warnings to be issued
for a file "subnot/a" if it is not removed when calling:

hg remove -S "subnot/a"
Anton Shestakov - July 22, 2016, 11:50 a.m.
22.07.2016, 19:43, "Hannes Oldenburg" <hannes.christian.oldenburg@gmail.com>:
> # HG changeset patch
> # User Hannes Oldenburg hannes.christian.oldenburg@gmail.com
> # Date 1469186982 0
> # Fri Jul 22 11:29:42 2016 +0000
> # Branch stable
> # Node ID 8549f914ebc26442248701789a45feda94d979d7
> # Parent d3df009ab1175a6792549b51ae66486dd98f398b
> cmdutil: warnings not issued in remove if subrepopath overlaps
>
> Previously a subrepository "sub" would cause no warnings to be issued
> for a file "subnot/a" if it is not removed when calling:
>
> hg remove -S "subnot/a"
>
> diff -r d3df009ab117 -r 8549f914ebc2 mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py Wed Jul 20 14:12:45 2016 -0500
> +++ b/mercurial/cmdutil.py Fri Jul 22 11:29:42 2016 +0000
> @@ -2481,7 +2481,7 @@
>      for f in files:
>          def insubrepo():
>              for subpath in wctx.substate:
> - if f.startswith(subpath):
> + if f.startswith(subpath + '/'):
>                      return True
>              return False
>
> diff -r d3df009ab117 -r 8549f914ebc2 tests/test-subrepo.t
> --- a/tests/test-subrepo.t Wed Jul 20 14:12:45 2016 -0500
> +++ b/tests/test-subrepo.t Fri Jul 22 11:29:42 2016 +0000
> @@ -53,6 +53,15 @@
>    7cf8cfea66e410e8e3336508dfeec07b3192de51
>    .hgsub .hgsubstate
>
> +Subrepopath wich overlaps with filepath, does not change warnings in remove()

"which".

> +
> + $ mkdir snot
> + $ touch snot/file
> + $ hg remove -S snot/file
> + not removing snot/file: file is untracked
> + [1]
> + $ rm -r snot
> +
>  Revert subrepo and test subrepo fileset keyword:
>
>    $ echo b > s/a

The rest looks fine to me, but I'm not even using subrepos.
Yuya Nishihara - July 22, 2016, 2:52 p.m.
On Fri, 22 Jul 2016 19:50:53 +0800, Anton Shestakov wrote:
> 22.07.2016, 19:43, "Hannes Oldenburg" <hannes.christian.oldenburg@gmail.com>:
> > # HG changeset patch
> > # User Hannes Oldenburg hannes.christian.oldenburg@gmail.com
> > # Date 1469186982 0
> > # Fri Jul 22 11:29:42 2016 +0000
> > # Branch stable
> > # Node ID 8549f914ebc26442248701789a45feda94d979d7
> > # Parent d3df009ab1175a6792549b51ae66486dd98f398b
> > cmdutil: warnings not issued in remove if subrepopath overlaps
> >
> > Previously a subrepository "sub" would cause no warnings to be issued
> > for a file "subnot/a" if it is not removed when calling:
> >
> > hg remove -S "subnot/a"
> >
> > diff -r d3df009ab117 -r 8549f914ebc2 mercurial/cmdutil.py
> > --- a/mercurial/cmdutil.py Wed Jul 20 14:12:45 2016 -0500
> > +++ b/mercurial/cmdutil.py Fri Jul 22 11:29:42 2016 +0000
> > @@ -2481,7 +2481,7 @@
> >      for f in files:
> >          def insubrepo():
> >              for subpath in wctx.substate:
> > - if f.startswith(subpath):
> > + if f.startswith(subpath + '/'):
> >                      return True
> >              return False
> >
> > diff -r d3df009ab117 -r 8549f914ebc2 tests/test-subrepo.t
> > --- a/tests/test-subrepo.t Wed Jul 20 14:12:45 2016 -0500
> > +++ b/tests/test-subrepo.t Fri Jul 22 11:29:42 2016 +0000
> > @@ -53,6 +53,15 @@
> >    7cf8cfea66e410e8e3336508dfeec07b3192de51
> >    .hgsub .hgsubstate
> >
> > +Subrepopath wich overlaps with filepath, does not change warnings in remove()  
> 
> "which".

Fixed and queued, thanks.
Yuya Nishihara - July 22, 2016, 3:26 p.m.
On Fri, 22 Jul 2016 23:52:19 +0900, Yuya Nishihara wrote:
> On Fri, 22 Jul 2016 19:50:53 +0800, Anton Shestakov wrote:
> > 22.07.2016, 19:43, "Hannes Oldenburg" <hannes.christian.oldenburg@gmail.com>:
> > > # HG changeset patch
> > > # User Hannes Oldenburg hannes.christian.oldenburg@gmail.com
> > > # Date 1469186982 0
> > > # Fri Jul 22 11:29:42 2016 +0000
> > > # Branch stable
> > > # Node ID 8549f914ebc26442248701789a45feda94d979d7
> > > # Parent d3df009ab1175a6792549b51ae66486dd98f398b
> > > cmdutil: warnings not issued in remove if subrepopath overlaps
> > >
> > > Previously a subrepository "sub" would cause no warnings to be issued
> > > for a file "subnot/a" if it is not removed when calling:
> > >
> > > hg remove -S "subnot/a"
> > >
> > > diff -r d3df009ab117 -r 8549f914ebc2 mercurial/cmdutil.py
> > > --- a/mercurial/cmdutil.py Wed Jul 20 14:12:45 2016 -0500
> > > +++ b/mercurial/cmdutil.py Fri Jul 22 11:29:42 2016 +0000
> > > @@ -2481,7 +2481,7 @@
> > >      for f in files:
> > >          def insubrepo():
> > >              for subpath in wctx.substate:
> > > - if f.startswith(subpath):
> > > + if f.startswith(subpath + '/'):
> > >                      return True
> > >              return False
> > >
> > > diff -r d3df009ab117 -r 8549f914ebc2 tests/test-subrepo.t
> > > --- a/tests/test-subrepo.t Wed Jul 20 14:12:45 2016 -0500
> > > +++ b/tests/test-subrepo.t Fri Jul 22 11:29:42 2016 +0000
> > > @@ -53,6 +53,15 @@
> > >    7cf8cfea66e410e8e3336508dfeec07b3192de51
> > >    .hgsub .hgsubstate
> > >
> > > +Subrepopath wich overlaps with filepath, does not change warnings in remove()  
> > 
> > "which".
> 
> Fixed and queued, thanks.

Oops, I got the following test failure:

-- a/tests/test-subrepo-deep-nested-change.t
+++ b/tests/test-subrepo-deep-nested-change.t

   $ hg remove -I 're:.*.txt' sub1
   \r (no-eol) (esc)
   searching [==========================================>] 1/1\r (no-eol) (esc)
                                                               \r (no-eol) (esc)
   \r (no-eol) (esc)
   deleting [===========================================>] 1/1\r (no-eol) (esc)
                                                               \r (no-eol) (esc)
+  not removing sub1: no tracked files
+  [1]

New behavior seems wrong since "sub1" is a subrepo and a subrepo directory
can't be empty by "hg remove".

Patch

diff -r d3df009ab117 -r 8549f914ebc2 mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Wed Jul 20 14:12:45 2016 -0500
+++ b/mercurial/cmdutil.py	Fri Jul 22 11:29:42 2016 +0000
@@ -2481,7 +2481,7 @@ 
     for f in files:
         def insubrepo():
             for subpath in wctx.substate:
-                if f.startswith(subpath):
+                if f.startswith(subpath + '/'):
                     return True
             return False
 
diff -r d3df009ab117 -r 8549f914ebc2 tests/test-subrepo.t
--- a/tests/test-subrepo.t	Wed Jul 20 14:12:45 2016 -0500
+++ b/tests/test-subrepo.t	Fri Jul 22 11:29:42 2016 +0000
@@ -53,6 +53,15 @@ 
   7cf8cfea66e410e8e3336508dfeec07b3192de51
   .hgsub .hgsubstate
 
+Subrepopath wich overlaps with filepath, does not change warnings in remove()
+
+  $ mkdir snot
+  $ touch snot/file
+  $ hg remove -S snot/file
+  not removing snot/file: file is untracked
+  [1]
+  $ rm -r snot
+
 Revert subrepo and test subrepo fileset keyword:
 
   $ echo b > s/a