changeset 25114:d1d69ca78883

match: add match.ispartial() match.ispartial() will return the opposite of match.always() in core, but this function will be extensible by extensions to produce another result even if match.always() will be untouched. This will be useful for narrowhg, where ispartial() will return False even if the match won't always match. This would happen in the case where the only time the match function is False is when the path is outside of the narrow spec.
author Drew Gottlieb <drgott@google.com>
date Fri, 15 May 2015 15:43:26 -0700
parents 0ca8410ea345
children 5548f558db3d
files mercurial/localrepo.py mercurial/match.py
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Sat May 16 11:28:04 2015 -0700
+++ b/mercurial/localrepo.py	Fri May 15 15:43:26 2015 -0700
@@ -1377,7 +1377,7 @@
             wctx = self[None]
             merge = len(wctx.parents()) > 1
 
-            if not force and merge and not match.always():
+            if not force and merge and match.ispartial():
                 raise util.Abort(_('cannot partially commit a merge '
                                    '(do not specify files or patterns)'))
 
--- a/mercurial/match.py	Sat May 16 11:28:04 2015 -0700
+++ b/mercurial/match.py	Fri May 15 15:43:26 2015 -0700
@@ -186,6 +186,14 @@
         - optimization might be possible and necessary.'''
         return self._always
 
+    def ispartial(self):
+        '''True if the matcher won't always match.
+
+        Although it's just the inverse of _always in this implementation,
+        an extenion such as narrowhg might make it return something
+        slightly different.'''
+        return not self._always
+
     def isexact(self):
         return self.matchfn == self.exact