# HG changeset patch # User Siddharth Agarwal # Date 1447483071 28800 # Node ID bd19561b98d9cf610afc92a34edc4e1579c12d72 # Parent c48fee950ce4f0d846ac093a7fb5fb8bd072011f 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 -r c48fee950ce4 -r bd19561b98d9 mercurial/context.py --- a/mercurial/context.py Fri Nov 13 23:01:36 2015 -0800 +++ b/mercurial/context.py Fri Nov 13 22:37:51 2015 -0800 @@ -747,11 +747,15 @@ 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