<div dir="ltr"><br><br><div class="gmail_quote">On Fri, May 15, 2015 at 3:44 PM Drew Gottlieb <<a href="mailto:drgott@google.com">drgott@google.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Drew Gottlieb <<a href="mailto:drgott@google.com" target="_blank">drgott@google.com</a>><br>
# Date 1431729806 25200<br>
#      Fri May 15 15:43:26 2015 -0700<br>
# Node ID fd530304121bd3c2fcbb23f5ec2052b47e24e0a7<br>
# Parent  2f34746c27dfd9d4ff51c1f0081526438ded0c04<br>
match: add match.ispartial()<br>
<br>
match.ispartial() will return the opposite of match.always() in core, but this<br>
function will be extensible by extensions to produce another result even<br>
if match.always() will be untouched.<br>
<br>
This will be useful for narrowhg, where ispartial() will return False even if<br>
the match won't always match. This would happen in the case where the only<br>
time the match function is False is when the path is outside of the narrow<br>
spec.<br>
<br>
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py<br>
--- a/mercurial/localrepo.py<br>
+++ b/mercurial/localrepo.py<br>
@@ -1377,7 +1377,7 @@<br>
             wctx = self[None]<br>
             merge = len(wctx.parents()) > 1<br>
<br>
-            if not force and merge and not match.always():<br>
+            if not force and merge and match.ispartial():<br></blockquote><div><br></div><div>To take one step back, why does the narrow extension need to pass in a non-always matcher? I looked briefly at localrepo.commit() and it wasn't clear to me for which uses of the matcher you need to use a modified matcher (presumably one that matches the narrow clone).</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                 raise util.Abort(_('cannot partially commit a merge '<br>
                                    '(do not specify files or patterns)'))<br>
<br>
diff --git a/mercurial/match.py b/mercurial/match.py<br>
--- a/mercurial/match.py<br>
+++ b/mercurial/match.py<br>
@@ -186,6 +186,14 @@<br>
         - optimization might be possible and necessary.'''<br>
         return self._always<br>
<br>
+    def ispartial(self):<br>
+        '''True if the matcher won't always match.<br>
+<br>
+        Although it's just the inverse of _always in this implementation,<br>
+        an extenion such as narrowhg might make it return something<br>
+        slightly different.'''<br>
+        return not self._always<br>
+<br>
     def isexact(self):<br>
         return self.matchfn == self.exact<br>
<br>
_______________________________________________<br>
Mercurial-devel mailing list<br>
<a href="mailto:Mercurial-devel@selenic.com" target="_blank">Mercurial-devel@selenic.com</a><br>
<a href="http://selenic.com/mailman/listinfo/mercurial-devel" target="_blank">http://selenic.com/mailman/listinfo/mercurial-devel</a><br>
</blockquote></div></div>