[PATCH 5 of 6] changeset_printer: use node.wdirrev to calculate meaningful parentrevs

Yuya Nishihara yuya at tcha.org
Thu Jul 2 10:17:04 CDT 2015


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1435842186 -32400
#      Thu Jul 02 22:03:06 2015 +0900
# Node ID 2286ea45d24c150d9ca9d0bc55c8c9303260abff
# Parent  d1cba8551345ecb42c4e4ca235b6cd0e40055f31
changeset_printer: use node.wdirrev to calculate meaningful parentrevs

Because we defined the working-directory revision is INT_MAX, it makes sense
that "hg log -r 'wdir()'" displays the "parent:" field. This is the same for
two revisions that are semantically contiguous but the intermediate revisions
are hidden.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1272,7 +1272,7 @@ class changeset_printer(object):
             return parents
         if self.ui.debugflag:
             return [parents[0], self.repo['null']]
-        if parents[0].rev() >= scmutil.intrev(self.repo, ctx.rev()) - 1:
+        if parents[0].rev() >= scmutil.intrev(ctx.rev()) - 1:
             return []
         return parents
 
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -6,7 +6,7 @@
 # GNU General Public License version 2 or any later version.
 
 from i18n import _
-from mercurial.node import nullrev
+from mercurial.node import nullrev, wdirrev
 import util, error, osutil, revset, similar, encoding, phases
 import pathutil
 import match as matchmod
@@ -662,11 +662,11 @@ def rcpath():
             _rcpath = osrcpath()
     return _rcpath
 
-def intrev(repo, rev):
+def intrev(rev):
     """Return integer for a given revision that can be used in comparison or
     arithmetic operation"""
     if rev is None:
-        return len(repo)
+        return wdirrev
     return rev
 
 def revsingle(repo, revspec, default='.'):
diff --git a/tests/test-log.t b/tests/test-log.t
--- a/tests/test-log.t
+++ b/tests/test-log.t
@@ -1627,6 +1627,7 @@ working-directory revision requires spec
 
   $ hg log -r 'wdir()'
   changeset:   0:65624cd9070a+
+  parent:      0:65624cd9070a
   user:        test
   date:        [A-Za-z0-9:+ ]+ (re)
   


More information about the Mercurial-devel mailing list