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

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 19, 2014, 10:56 p.m.
Message ID <5358071e65be2fd330b4.1408488979@mimosa>
Download mbox | patch
Permalink /patch/5528/
State Changes Requested
Headers show

Comments

Yuya Nishihara - Aug. 19, 2014, 10:56 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.

Patch

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