[PATCH 5 of 8] forget: replace match.bad() monkey patching with match.badmatch()

Matt Harbison mharbison72 at gmail.com
Thu Jun 4 23:00:50 CDT 2015


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1433469196 14400
#      Thu Jun 04 21:53:16 2015 -0400
# Node ID 96d56f524bd1e549344d7329421dbb4d887a8b95
# Parent  41df7782b13008319e8710fd87bb3f36ec304614
forget: replace match.bad() monkey patching with match.badmatch()

The previous code didn't restore the original method, but it looks like the
worst that would happen is junk added to a list that had already been processed
by previous subrepo invocation(s).

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2251,11 +2251,11 @@
 def forget(ui, repo, match, prefix, explicitonly):
     join = lambda f: os.path.join(prefix, f)
     bad = []
-    oldbad = match.bad
-    match.bad = lambda x, y: bad.append(x) or oldbad(x, y)
+    badfn = lambda x, y: bad.append(x) or match.bad(x, y)
     wctx = repo[None]
     forgot = []
-    s = repo.status(match=match, clean=True)
+
+    s = repo.status(match=matchmod.badmatch(match, badfn), clean=True)
     forget = sorted(s[0] + s[1] + s[3] + s[6])
     if explicitonly:
         forget = [f for f in forget if match.exact(f)]


More information about the Mercurial-devel mailing list