revset: fix a crash in parents() when 'wdir()' is in the set
The crash was "TypeError: expected string or Unicode object, NoneType found"
down in revlog.parentrevs(). This fixes heads() too (which is where I found
it.)
--- a/mercurial/revset.py Sun Jun 28 13:38:03 2015 -0400
+++ b/mercurial/revset.py Mon Jun 29 10:34:56 2015 -0400
@@ -1468,7 +1468,10 @@
ps = set()
cl = repo.changelog
for r in getset(repo, fullreposet(repo), x):
- ps.update(cl.parentrevs(r))
+ if r is None:
+ ps.update(p.rev() for p in repo[r].parents())
+ else:
+ ps.update(cl.parentrevs(r))
ps -= set([node.nullrev])
return subset & ps
--- a/tests/test-add.t Sun Jun 28 13:38:03 2015 -0400
+++ b/tests/test-add.t Mon Jun 29 10:34:56 2015 -0400
@@ -75,6 +75,13 @@
$ hg ci -m 0 --traceback
+ $ hg log -r "heads(. or wdir() & file('**'))"
+ changeset: 0:* (glob)
+ tag: tip
+ user: test
+ date: Thu Jan 01 00:00:00 1970 +0000
+ summary: 0
+
should fail
$ hg add a
@@ -99,6 +106,15 @@
M a
? a.orig
+wdir doesn't cause a crash, and can be dynamically selected if dirty
+
+ $ hg log -r "heads(. or wdir() & file('**'))"
+ changeset: 2:*+ (glob)
+ parent: 2:* (glob)
+ parent: 1:* (glob)
+ user: test
+ date: * (glob)
+
should fail
$ hg add a