[PATCH] cmdutil: extract duplicate definitions of matchessubrepo in files() and remove()
Hannes Oldenburg
hannes.christian.oldenburg at gmail.com
Sun Jul 17 07:56:36 UTC 2016
# HG changeset patch
# User Hannes Oldenburg zerstroyer at gmail.com
# Date 1468660399 0
# Sat Jul 16 09:13:19 2016 +0000
# Branch stable
# Node ID eb4a974d3a18826632600dabe82c8fe453b65e20
# Parent a7d1532b26a17bbaace43124cd415dcb709b08e2
cmdutil: extract duplicate definitions of matchessubrepo in files() and remove()
diff -r a7d1532b26a1 -r eb4a974d3a18 mercurial/cmdutil.py
--- a/mercurial/cmdutil.py Sat Jul 02 09:41:40 2016 -0700
+++ b/mercurial/cmdutil.py Sat Jul 16 09:13:19 2016 +0000
@@ -2396,6 +2396,10 @@
forgot.extend(f for f in forget if f not in rejected)
return bad, forgot
+def matchessubrepo(m,subpath):
+ return (m.exact(subpath)
+ or any(f.startswith(subpath + '/') for f in m.files()))
+
def files(ui, ctx, m, fm, fmt, subrepos):
rev = ctx.rev()
ret = 1
@@ -2413,11 +2417,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 matchessubrepo(m,subpath):
sub = ctx.sub(subpath)
try:
submatch = matchmod.subdirmatcher(subpath, m)
@@ -2448,14 +2448,6 @@
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):
ui.progress(_('searching'), count, total=total, unit=_('subrepos'))
More information about the Mercurial-devel
mailing list