diff mercurial/cmdutil.py @ 29758:2372182e505b

match: added matchessubrepo method to matcher Previously there were three local implementations of this function in cmdutil.files, cmdutil.remove and scmutil.addremove.
author Hannes Oldenburg <hannes.christian.oldenburg@gmail.com>
date Tue, 09 Aug 2016 09:02:51 +0000
parents 84a8de5ac901
children 142ae01820a3
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Mon Aug 08 22:06:07 2016 -0700
+++ b/mercurial/cmdutil.py	Tue Aug 09 09:02:51 2016 +0000
@@ -2415,11 +2415,7 @@
         ret = 0
 
     for subpath in sorted(ctx.substate):
-        def matchessubrepo(subpath):
-            return (m.exact(subpath)
-                    or any(f.startswith(subpath + '/') for f in m.files()))
-
-        if subrepos or matchessubrepo(subpath):
+        if subrepos or m.matchessubrepo(subpath):
             sub = ctx.sub(subpath)
             try:
                 submatch = matchmod.subdirmatcher(subpath, m)
@@ -2450,16 +2446,8 @@
     total = len(subs)
     count = 0
     for subpath in subs:
-        def matchessubrepo(matcher, subpath):
-            if matcher.exact(subpath):
-                return True
-            for f in matcher.files():
-                if f.startswith(subpath):
-                    return True
-            return False
-
         count += 1
-        if subrepos or matchessubrepo(m, subpath):
+        if subrepos or m.matchessubrepo(subpath):
             ui.progress(_('searching'), count, total=total, unit=_('subrepos'))
 
             sub = wctx.sub(subpath)