[PATCH 5 of 8 RFC] committablectx: override hex() to return p1 hash with "+" suffix

Yuya Nishihara yuya at tcha.org
Tue Aug 19 17:56:19 CDT 2014


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1408183124 -32400
#      Sat Aug 16 18:58:44 2014 +0900
# Node ID 5358071e65be2fd330b45d5989198101ae6b01d6
# Parent  a24e178a381bc389079e7c09ffe21f757ba93029
committablectx: override hex() to return p1 hash with "+" suffix

Originally hex() didn't work because node() is None.  Since hex() is the method
to return ascii representation of node(), it won't be problem to contain "+"
character.

This change can simplify annotation of working-directory revision.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1002,6 +1002,9 @@ class committablectx(basectx):
     def __nonzero__(self):
         return True
 
+    def hex(self):
+        return self._parents[0].hex() + "+"
+
     def _buildflagfunc(self):
         # Create a fallback function for getting file flags when the
         # filesystem doesn't support them


More information about the Mercurial-devel mailing list