<div dir="ltr"><div>I tried to create a bug and dug a little bit into the code, and although it wrongly goes into the if statement, subdirmatcher seems to perform the same check again anyways. Or did you observe a bug? Here is what i tried: <br><br>mkdir r && cd r && hg init;<br><br>echo s = s > .hgsub;<br>echo sub = sub >> .hgsub;<br><br>hg add .hgsub;<br><br>mkdir s sub && hg init s && hg init sub;<br>touch s/a;<br>touch sub/a;<br><br>hg -R s add s/a;<br>hg -R sub add sub/a;<br><br>hg -R s commit -m "first subrepo first commit";<br>hg -R sub commit -m "second subrepo first commit";<br><br>hg commit -m "root repo first commit";<br><br>hg files -S s/a;<br><br>hg remove --verbose s/a; <br><br></div><div>#Output:<br></div>#s/a<br>#removing s/a<br><br><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 20, 2016 at 3:09 AM, Matt Harbison <span dir="ltr"><<a href="mailto:mharbison72@gmail.com" target="_blank">mharbison72@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">(+CC list)<span class=""><br>
<br>
On Tue, 19 Jul 2016 09:13:51 -0400, Augie Fackler <<a href="mailto:raf@durin42.com" target="_blank">raf@durin42.com</a>> wrote:<br>
<br>
</span><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Mon, Jul 18, 2016 at 07:56:54PM +0000, Zergling wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hm sorry, that was the the wrong patch version. I'm gonna send again with<br>
whitespace fixed if it's worth it and i guess i should patch against<br>
default for this.<br>
</blockquote>
<br>
Looks like a good cleanup, I might make matchessubrepo have a leading<br>
_ so it's clear it's module-private (unless you have plans for it<br>
beyond cmdutil).<br>
<br>
We just entered a code freeze for hg 3.9, so if you could send this on<br>
or after August 1 that'll be best. Thanks!<br>
</blockquote>
<br></span><span class="">
Actually, I think this might fix a bug.  Note that '/' is appended to<br>
subpath before doing the prefix test in the second hunk, but not the<br>
third.  Therefore, 'path/to/subrepo' matches 'path/to/subrepo/foo' in the<br>
first case, but also matches 'path/to/subrepository/foo' in the second.<br>
scmutil.addremove() also has this bit of code, and needs to be fixed I<br>
think.  I meant to fix this awhile ago.<br>
<br>
Hannes- maybe append '/' to the two cases that don't have it to keep this<br>
simple, and submit now (with tests).  Then after the freeze lifts on Aug<br>
1, add the utility routine to the matcher class and use it in these three<br>
places.<br>
<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br><div><div class="h5">
On Sun, Jul 17, 2016 at 7:56 AM, Hannes Oldenburg <<br>
<a href="mailto:hannes.christian.oldenburg@gmail.com" target="_blank">hannes.christian.oldenburg@gmail.com</a>> wrote:<br>
<br>
> # HG changeset patch<br>
> # User Hannes Oldenburg <a href="mailto:zerstroyer@gmail.com" target="_blank">zerstroyer@gmail.com</a><br>
> # Date 1468660399 0<br>
> #      Sat Jul 16 09:13:19 2016 +0000<br>
> # Branch stable<br>
> # Node ID eb4a974d3a18826632600dabe82c8fe453b65e20<br>
> # Parent  a7d1532b26a17bbaace43124cd415dcb709b08e2<br>
> cmdutil: extract duplicate definitions of matchessubrepo in files() and<br>
> remove()<br>
><br>
> diff -r a7d1532b26a1 -r eb4a974d3a18 mercurial/cmdutil.py<br>
> --- a/mercurial/cmdutil.py      Sat Jul 02 09:41:40 2016 -0700<br>
> +++ b/mercurial/cmdutil.py      Sat Jul 16 09:13:19 2016 +0000<br>
> @@ -2396,6 +2396,10 @@<br>
>      forgot.extend(f for f in forget if f not in rejected)<br>
>      return bad, forgot<br>
><br>
> +def matchessubrepo(m,subpath):<br>
> +    return (m.exact(subpath)<br>
> +            or any(f.startswith(subpath + '/') for f in m.files()))<br>
> +<br>
>  def files(ui, ctx, m, fm, fmt, subrepos):<br>
>      rev = ctx.rev()<br>
>      ret = 1<br>
> @@ -2413,11 +2417,7 @@<br>
>          ret = 0<br>
><br>
>      for subpath in sorted(ctx.substate):<br>
> -        def matchessubrepo(subpath):<br>
> -            return (m.exact(subpath)<br>
> -                    or any(f.startswith(subpath + '/') for f in<br>
> m.files()))<br>
> -<br>
> -        if subrepos or matchessubrepo(subpath):<br>
> +        if subrepos or matchessubrepo(m,subpath):<br>
>              sub = ctx.sub(subpath)<br>
>              try:<br>
>                  submatch = matchmod.subdirmatcher(subpath, m)<br>
> @@ -2448,14 +2448,6 @@<br>
>      total = len(subs)<br>
>      count = 0<br>
>      for subpath in subs:<br>
> -        def matchessubrepo(matcher, subpath):<br>
> -            if matcher.exact(subpath):<br>
> -                return True<br>
> -            for f in matcher.files():<br>
> -                if f.startswith(subpath):<br>
> -                    return True<br>
> -            return False<br>
> -<br>
>          count += 1<br>
>          if subrepos or matchessubrepo(m, subpath):<br>
>              ui.progress(_('searching'), count, total=total,<br>
> unit=_('subrepos'))<br>
> _______________________________________________<br>
> Mercurial-devel mailing list<br>
> <a href="mailto:Mercurial-devel@mercurial-scm.org" target="_blank">Mercurial-devel@mercurial-scm.org</a><br>
> <a href="https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel" rel="noreferrer" target="_blank">https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel</a><br>
><br>
</div></div></blockquote><div><div class="h5">
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
_______________________________________________<br>
Mercurial-devel mailing list<br>
<a href="mailto:Mercurial-devel@mercurial-scm.org" target="_blank">Mercurial-devel@mercurial-scm.org</a><br>
<a href="https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel" rel="noreferrer" target="_blank">https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel</a><br>
</blockquote>
_______________________________________________<br>
Mercurial-devel mailing list<br>
<a href="mailto:Mercurial-devel@mercurial-scm.org" target="_blank">Mercurial-devel@mercurial-scm.org</a><br>
<a href="https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel" rel="noreferrer" target="_blank">https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel</a><br>
</div></div></blockquote>
</blockquote></div><br></div>