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

login
register
mail settings
Submitter Yuya Nishihara
Date March 19, 2015, 4:23 p.m.
Message ID <4d7b156a0f78a14120e0.1426782193@mimosa>
Download mbox | patch
Permalink /patch/8166/
State Accepted
Commit 065b886f61c6255c0ae5f9e4b2ad3945d2d7973f
Headers show

Comments

Yuya Nishihara - March 19, 2015, 4:23 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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().

Patch

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):