Submitter | Pulkit Goyal |
---|---|
Date | Feb. 23, 2017, noon |
Message ID | <e86b701628b33640c537.1487851201@pulkit-goyal> |
Download | mbox | patch |
Permalink | /patch/18747/ |
State | Changes Requested |
Headers | show |
Comments
On Thu, 23 Feb 2017 17:30:01 +0530, Pulkit Goyal wrote: > # HG changeset patch > # User Pulkit Goyal <7895pulkit@gmail.com> > # Date 1487801796 -19800 > # Thu Feb 23 03:46:36 2017 +0530 > # Node ID e86b701628b33640c537e7377bbee8b69f22e390 > # Parent 4572027bbe6795e66758120375f647c1c1804195 > revset: make wdir() work with parent '^' operator(issue4905) > > Before this patch, running `hg log -r 'wdir()^'` returns error. > > diff -r 4572027bbe67 -r e86b701628b3 mercurial/revset.py > --- a/mercurial/revset.py Wed Feb 22 18:33:00 2017 +0530 > +++ b/mercurial/revset.py Thu Feb 23 03:46:36 2017 +0530 > @@ -1399,7 +1399,10 @@ > ps = set() > cl = repo.changelog > for r in getset(repo, fullreposet(repo), x): > - ps.add(cl.parentrevs(r)[0]) > + if r == node.wdirrev: > + ps.add(subset.last()) > + else: > + ps.add(cl.parentrevs(r)[0]) IMHO, we shouldn't add this kind of branch to every place where wdir() could be passed. That would be error-prone and could hurt performance of non-wdir() cases. Instead, I'm thinking of adding WdirRevIsNotSupportedByUnderlyingStorage exception. It will be raised by revlog if wdir revision is passed, for example, and be caught where we know workingctx and fall back to slow ctx-lookup path.
Patch
diff -r 4572027bbe67 -r e86b701628b3 mercurial/revset.py --- a/mercurial/revset.py Wed Feb 22 18:33:00 2017 +0530 +++ b/mercurial/revset.py Thu Feb 23 03:46:36 2017 +0530 @@ -1399,7 +1399,10 @@ ps = set() cl = repo.changelog for r in getset(repo, fullreposet(repo), x): - ps.add(cl.parentrevs(r)[0]) + if r == node.wdirrev: + ps.add(subset.last()) + else: + ps.add(cl.parentrevs(r)[0]) ps -= set([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 -r 4572027bbe67 -r e86b701628b3 tests/test-revset.t --- a/tests/test-revset.t Wed Feb 22 18:33:00 2017 +0530 +++ b/tests/test-revset.t Thu Feb 23 03:46:36 2017 +0530 @@ -1221,6 +1221,8 @@ Test working-directory revision $ hg debugrevspec 'wdir()' 2147483647 + $ hg debugrevspec 'wdir()^' + 9 $ hg debugrevspec 'tip or wdir()' 9 2147483647