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

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


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1433469356 14400
#      Thu Jun 04 21:55:56 2015 -0400
# Node ID 6316bb0636ce6669559c16f466d1065177ca637f
# Parent  96d56f524bd1e549344d7329421dbb4d887a8b95
cat: 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/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2437,22 +2437,16 @@
             return 0
 
     # Don't warn about "missing" files that are really in subrepos
-    bad = matcher.bad
-
     def badfn(path, msg):
         for subpath in ctx.substate:
             if path.startswith(subpath):
                 return
-        bad(path, msg)
-
-    matcher.bad = badfn
-
-    for abs in ctx.walk(matcher):
+        matcher.bad(path, msg)
+
+    for abs in ctx.walk(matchmod.badmatch(matcher, badfn)):
         write(abs)
         err = 0
 
-    matcher.bad = bad
-
     for subpath in sorted(ctx.substate):
         sub = ctx.sub(subpath)
         try:


More information about the Mercurial-devel mailing list