changeset 25435:a592a6a6f4fe

context: 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.
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 04 Jun 2015 21:37:59 -0400
parents 5984dd42e140
children 9724cbe2d546
files mercurial/context.py
diffstat 1 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Thu Jun 04 21:25:07 2015 -0400
+++ b/mercurial/context.py	Thu Jun 04 21:37:59 2015 -0400
@@ -9,7 +9,7 @@
 from i18n import _
 import mdiff, error, util, scmutil, subrepo, patch, encoding, phases
 import match as matchmod
-import copy, os, errno, stat
+import os, errno, stat
 import obsolete as obsmod
 import repoview
 import fileset
@@ -595,19 +595,17 @@
     def walk(self, match):
         '''Generates matching file names.'''
 
-        # Override match.bad method to have message with nodeid
-        match = copy.copy(match)
-        oldbad = match.bad
+        # Wrap match.bad method to have message with nodeid
         def bad(fn, msg):
             # The manifest doesn't know about subrepos, so don't complain about
             # paths into valid subrepos.
             if any(fn == s or fn.startswith(s + '/')
                    for s in self.substate):
                 return
-            oldbad(fn, _('no such file in rev %s') % self)
-        match.bad = bad
+            match.bad(fn, _('no such file in rev %s') % self)
 
-        return self._manifest.walk(match)
+        m = matchmod.badmatch(match, bad)
+        return self._manifest.walk(m)
 
     def matches(self, match):
         return self.walk(match)