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

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


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1433467507 14400
#      Thu Jun 04 21:25:07 2015 -0400
# Node ID bc470c4470ea9d80c83b8d0c39cac4cd7a9d29ea
# Parent  ee8c63982085a4fadc83b6957d413866d1f21b28
addremove: replace match.bad() monkey patching with match.badmatch()

No known issues with the previous code since it restored the original method,
but this is cleaner.

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -850,15 +850,14 @@
                                  % join(subpath))
 
     rejected = []
-    origbad = m.bad
     def badfn(f, msg):
         if f in m.files():
-            origbad(f, msg)
+            m.bad(f, msg)
         rejected.append(f)
 
-    m.bad = badfn
-    added, unknown, deleted, removed, forgotten = _interestingfiles(repo, m)
-    m.bad = origbad
+    badmatch = matchmod.badmatch(m, badfn)
+    added, unknown, deleted, removed, forgotten = _interestingfiles(repo,
+                                                                    badmatch)
 
     unknownset = set(unknown + forgotten)
     toprint = unknownset.copy()


More information about the Mercurial-devel mailing list