diff mercurial/match.py @ 32444:952017471f93

match: implement __repr__() and update users (API) fsmonitor and debugignore currently access matcher fields that I would consider implementation details, namely patternspat, includepat, and excludepat. Let' instead implement __repr__() and have the few users use that instead. Marked (API) because the fields can now be None.
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 22 May 2017 11:08:18 -0700
parents 284b18303f61
children 9695aca1a3a0
line wrap: on
line diff
--- a/mercurial/match.py	Mon May 22 10:41:32 2017 -0700
+++ b/mercurial/match.py	Mon May 22 11:08:18 2017 -0700
@@ -214,6 +214,9 @@
         self._anypats = bool(include or exclude)
         self._always = False
         self._pathrestricted = bool(include or exclude or patterns)
+        self.patternspat = None
+        self.includepat = None
+        self.excludepat = None
 
         # roots are directories which are recursively included/excluded.
         self._includeroots = set()
@@ -375,6 +378,11 @@
     def prefix(self):
         return not self.always() and not self.isexact() and not self.anypats()
 
+    def __repr__(self):
+        return ('<matcher files=%r, patterns=%r, includes=%r, excludes=%r>' %
+                (self._files, self.patternspat, self.includepat,
+                 self.excludepat))
+
 class subdirmatcher(matcher):
     """Adapt a matcher to work on a subdirectory only.