From patchwork Tue Jun 30 14:26:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [V2] revset: fix a crash in parents() when 'wdir()' is in the set From: Matt Harbison X-Patchwork-Id: 9830 Message-Id: To: mercurial-devel@selenic.com Cc: matt_harbison@yahoo.com Date: Tue, 30 Jun 2015 10:26:35 -0400 # HG changeset patch # User Matt Harbison # Date 1435588496 14400 # Mon Jun 29 10:34:56 2015 -0400 # Node ID b84b980cf15bdda20c474f8f5ff6b3e367164f7e # 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(p.rev() for p in repo[r].parents()) + 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