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

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 19, 2014, 10:56 p.m.
Message ID <a24e178a381bc389079e.1408488978@mimosa>
Download mbox | patch
Permalink /patch/5527/
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 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().

Patch

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