[PATCH] revset: fix a crash in parents() when 'wdir()' is in the set
Matt Harbison
mharbison at attotech.com
Mon Jun 29 17:15:08 UTC 2015
# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1435588496 14400
# Mon Jun 29 10:34:56 2015 -0400
# Node ID 6fb8a76fa2afa847734c15ef7b2e22a94505c591
# Parent ff5172c830022b64cc5bd1bae36b2276e9dc6e5d
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.)
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1468,7 +1468,10 @@ def parents(repo, subset, x):
ps = set()
cl = repo.changelog
for r in getset(repo, fullreposet(repo), x):
- ps.update(cl.parentrevs(r))
+ if r is None:
+ ps.update([repo['.'].rev()])
+ else:
+ ps.update(cl.parentrevs(r))
ps -= set([node.nullrev])
return subset & ps
diff --git a/tests/test-add.t b/tests/test-add.t
--- a/tests/test-add.t
+++ b/tests/test-add.t
@@ -75,6 +75,13 @@ should fail
$ 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 @@ should fail
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
More information about the Mercurial-devel
mailing list