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

login
register
mail settings
Submitter Matt Harbison
Date June 5, 2015, 4 a.m.
Message ID <6316bb0636ce6669559c.1433476851@Envy>
Download mbox | patch
Permalink /patch/9506/
State Accepted
Commit 7ce5a3230441f55b9c4349a9fbe84835aab93c20
Headers show

Comments

Matt Harbison - June 5, 2015, 4 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@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.

Patch

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: