Patchwork [3,of,7,mergedriver] filectx: allow custom comparators

mail settings
Submitter Siddharth Agarwal
Date Nov. 16, 2015, 11:46 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/11420/
State Accepted
Headers show


Siddharth Agarwal - Nov. 16, 2015, 11:46 p.m.
# HG changeset patch
# User Siddharth Agarwal <>
# Date 1447483071 28800
#      Fri Nov 13 22:37:51 2015 -0800
# Node ID 1ac068b89094bece99583ccfe22dae0b7db75a6c
# Parent  961c7229e7efb64e13cf50adb85ce09a3992252f
filectx: allow custom comparators

We're going to introduce other sorts of filectxes very soon, and we'd like the
cmp method to function properly (i.e. commutatively) for them. The only way to
make that happen is for this cmp method to call into that specialized one if
that defines a custom comparator.


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -747,11 +747,15 @@  class basefilectx(object):
     def islink(self):
         return 'l' in self.flags()
+    _customcmp = False
     def cmp(self, fctx):
         """compare with other file context
         returns True if different than fctx.
+        if fctx._customcmp:
+            return fctx.cmp(self)
         if (fctx._filerev is None
             and (self._repo._encodefilterpats
                  # if file data starts with '\1\n', empty metadata block is