[PATCH 4 of 8 RFC] context: add uncommitted() that can be used in place of "rev() is None"

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


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1408095671 -32400
#      Fri Aug 15 18:41:11 2014 +0900
# Node ID a24e178a381bc389079e7c09ffe21f757ba93029
# Parent  304c88eafb4283e72af2eae5e6a442c255052385
context: add uncommitted() that can be used in place of "rev() is None"

This attribute will be used to implement annotation of pseudo workingdir
revision.

I'm not sure if we should replace all "rev() is None" by uncommitted().

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -155,6 +155,8 @@ class basectx(object):
         return self._node
     def hex(self):
         return hex(self.node())
+    def uncommitted(self):
+        return self._rev is None or self._rev >= len(self._repo)
     def manifest(self):
         return self._manifest
     def phasestr(self):
@@ -687,6 +689,8 @@ class basefilectx(object):
         return self._changectx.node()
     def hex(self):
         return self._changectx.hex()
+    def uncommitted(self):
+        return self._changectx.uncommitted()
     def user(self):
         return self._changectx.user()
     def date(self):


More information about the Mercurial-devel mailing list