[PATCH 2 of 3 RFC V3] committablefilectx: override linkrev() to point to the associated changectx

Yuya Nishihara yuya at tcha.org
Thu Mar 19 11:23:13 CDT 2015


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1426775513 -32400
#      Thu Mar 19 23:31:53 2015 +0900
# Node ID 4d7b156a0f78a14120e04091e10c32fa6f45dab1
# Parent  ac80716bb799448df0181f5a3169b7242bdf8400
committablefilectx: override linkrev() to point to the associated changectx

This is necessary to annotate workingctx revision. basefilectx.linkrev() can't
be used because committablefilectx has no filelog.

committablefilectx looks for parents() from self._changectx. That means fctx
is linked to self._changectx, so linkrev() can simply be aliased to rev().

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1586,6 +1586,10 @@ class committablefilectx(basefilectx):
     def __nonzero__(self):
         return True
 
+    def linkrev(self):
+        # linked to self._changectx no matter if file is modified or not
+        return self.rev()
+
     def parents(self):
         '''return parent filectxs, following copies if necessary'''
         def filenode(ctx, path):


More information about the Mercurial-devel mailing list