changeset 21482:869a28d016e9

workingctx: override _matchstatus for parentworking case This patch encapsulate the logic for changing the match.bad function when comparing against the working directory's parent. Future patches will remove more of the 'if ... else' blocks in localrepo.status that test for this working directory parent case.
author Sean Farley <sean.michael.farley@gmail.com>
date Thu, 24 Apr 2014 08:32:28 -0500
parents 2f1567ef70ba
children 6adfc311eee8
files mercurial/context.py
diffstat 1 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Wed Apr 23 15:39:30 2014 -0500
+++ b/mercurial/context.py	Thu Apr 24 08:32:28 2014 -0500
@@ -1351,6 +1351,30 @@
                                                      listunknown)
         return s
 
+    def _matchstatus(self, other, s, match, listignored, listclean,
+                     listunknown):
+        """override the match method with a filter for directory patterns
+
+        We use inheritance to customize the match.bad method only in cases of
+        workingctx since it belongs only to the working directory when
+        comparing against the parent changeset.
+
+        If we aren't comparing against the working directory's parent, then we
+        just use the default match object sent to us.
+        """
+        superself = super(workingctx, self)
+        match = superself._matchstatus(other, s, match, listignored, listclean,
+                                       listunknown)
+        if other != self._repo['.']:
+            def bad(f, msg):
+                # 'f' may be a directory pattern from 'match.files()',
+                # so 'f not in ctx1' is not enough
+                if f not in other and f not in other.dirs():
+                    self._repo.ui.warn('%s: %s\n' %
+                                       (self._repo.dirstate.pathto(f), msg))
+            match.bad = bad
+        return match
+
     def status(self, ignored=False, clean=False, unknown=False, match=None):
         """Explicit status query
         Unless this method is used to query the working copy status, the