Patchwork [2,of,2] revset: make wdir() work with ancestorspec '~' operator

login
register
mail settings
Submitter Pulkit Goyal
Date Feb. 23, 2017, noon
Message ID <88fc32b91722498f17e4.1487851202@pulkit-goyal>
Download mbox | patch
Permalink /patch/18748/
State Changes Requested
Headers show

Comments

Pulkit Goyal - Feb. 23, 2017, noon
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1487801268 -19800
#      Thu Feb 23 03:37:48 2017 +0530
# Node ID 88fc32b91722498f17e4d8a48449e76986a171d7
# Parent  e86b701628b33640c537e7377bbee8b69f22e390
revset: make wdir() work with ancestorspec '~' operator

Before this patch, doing `hg log -r 'wdir()~n'` returns an error except for
n equals 0.

Patch

diff -r e86b701628b3 -r 88fc32b91722 mercurial/revset.py
--- a/mercurial/revset.py	Thu Feb 23 03:46:36 2017 +0530
+++ b/mercurial/revset.py	Thu Feb 23 03:37:48 2017 +0530
@@ -390,6 +390,9 @@ 
     ps = set()
     cl = repo.changelog
     for r in getset(repo, fullreposet(repo), x):
+        if r == node.wdirrev and n > 0:
+            n = n-1
+            r = subset.last()
         for i in range(n):
             r = cl.parentrevs(r)[0]
         ps.add(r)
diff -r e86b701628b3 -r 88fc32b91722 tests/test-revset.t
--- a/tests/test-revset.t	Thu Feb 23 03:46:36 2017 +0530
+++ b/tests/test-revset.t	Thu Feb 23 03:37:48 2017 +0530
@@ -1223,6 +1223,8 @@ 
   2147483647
   $ hg debugrevspec 'wdir()^'
   9
+  $ hg debugrevspec 'wdir()~4'
+  2
   $ hg debugrevspec 'tip or wdir()'
   9
   2147483647