Patchwork [3,of,3] revset: make `hg log -r 'wdir()^'` work (issue4905)

login
register
mail settings
Submitter Pulkit Goyal
Date May 19, 2017, 3:07 p.m.
Message ID <9310019e4eb9ae6e7d74.1495206474@workspace>
Download mbox | patch
Permalink /patch/20719/
State Accepted
Headers show

Comments

Pulkit Goyal - May 19, 2017, 3:07 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1495204605 -19800
#      Fri May 19 20:06:45 2017 +0530
# Node ID 9310019e4eb9ae6e7d740da88d89112ce85f7dd0
# Parent  e2a67243cdbcfef442f53ac8a566c91b9e34a93d
revset: make `hg log -r 'wdir()^'` work (issue4905)

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1408,7 +1408,10 @@ 
     ps = set()
     cl = repo.changelog
     for r in getset(repo, fullreposet(repo), x):
-        ps.add(cl.parentrevs(r)[0])
+        try:
+            ps.add(cl.parentrevs(r)[0])
+        except error.WdirRevNotSupportedError:
+            ps.add(repo[r].parents()[0].rev())
     ps -= {node.nullrev}
     # XXX we should turn this into a baseset instead of a set, smartset may do
     # some optimizations from the fact this is a baseset.
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -1221,6 +1221,15 @@ 
 Test working-directory revision
   $ hg debugrevspec 'wdir()'
   2147483647
+  $ hg debugrevspec 'wdir()^'
+  9
+  $ hg up 7
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg debugrevspec 'wdir()^'
+  7
+For tests consistency
+  $ hg up 9
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg debugrevspec 'tip or wdir()'
   9
   2147483647