Patchwork [1,of,2] subrepo: cleanup of subrepo filematcher logic

login
register
mail settings
Submitter Hannes Oldenburg
Date Aug. 16, 2016, 3:42 p.m.
Message ID <ad4abe10145930a10676.1471362153@localhost.localdomain>
Download mbox | patch
Permalink /patch/16323/
State Accepted
Headers show

Comments

Hannes Oldenburg - Aug. 16, 2016, 3:42 p.m.
# HG changeset patch
# User Hannes Oldenburg <hannes.christian.oldenburg@gmail.com>
# Date 1471335312 0
#      Tue Aug 16 08:15:12 2016 +0000
# Node ID ad4abe10145930a1067660221fb8e06bb5d03995
# Parent  997e8cf4d0a29d28759e38659736cb3d1cf9ef3f
subrepo: cleanup of subrepo filematcher logic

Previously in the worst case we iterated the files in matcher twice and
had a method only for this, which reimplemented logic in subdirmatchers
constructor. So we replaced the method with a subdirmatcher.files() call.

Patch

diff -r 997e8cf4d0a2 -r ad4abe101459 mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Sat Aug 13 04:21:42 2016 +0530
+++ b/mercurial/cmdutil.py	Tue Aug 16 08:15:12 2016 +0000
@@ -2415,10 +2415,10 @@ 
         ret = 0
 
     for subpath in sorted(ctx.substate):
-        if subrepos or m.matchessubrepo(subpath):
+        submatch = matchmod.subdirmatcher(subpath, m)
+        if (subrepos or m.exact(subpath) or any(submatch.files())):
             sub = ctx.sub(subpath)
             try:
-                submatch = matchmod.subdirmatcher(subpath, m)
                 recurse = m.exact(subpath) or subrepos
                 if sub.printfiles(ui, submatch, fm, fmt, recurse) == 0:
                     ret = 0
@@ -2447,12 +2447,11 @@ 
     count = 0
     for subpath in subs:
         count += 1
-        if subrepos or m.matchessubrepo(subpath):
+        submatch = matchmod.subdirmatcher(subpath, m)
+        if subrepos or m.exact(subpath) or any(submatch.files()):
             ui.progress(_('searching'), count, total=total, unit=_('subrepos'))
-
             sub = wctx.sub(subpath)
             try:
-                submatch = matchmod.subdirmatcher(subpath, m)
                 if sub.removefiles(submatch, prefix, after, force, subrepos,
                                    warnings):
                     ret = 1
diff -r 997e8cf4d0a2 -r ad4abe101459 mercurial/scmutil.py
--- a/mercurial/scmutil.py	Sat Aug 13 04:21:42 2016 +0530
+++ b/mercurial/scmutil.py	Tue Aug 16 08:15:12 2016 +0000
@@ -949,10 +949,10 @@ 
 
     wctx = repo[None]
     for subpath in sorted(wctx.substate):
-        if opts.get('subrepos') or m.matchessubrepo(subpath):
+        submatch = matchmod.subdirmatcher(subpath, m)
+        if opts.get('subrepos') or m.exact(subpath) or any(submatch.files()):
             sub = wctx.sub(subpath)
             try:
-                submatch = matchmod.subdirmatcher(subpath, m)
                 if sub.addremove(submatch, prefix, opts, dry_run, similarity):
                     ret = 1
             except error.LookupError: