[PATCH 3 of 6] revset: fix a crash with 'p1(wdir())'

Matt Harbison mharbison72 at gmail.com
Tue Jun 30 21:56:40 CDT 2015


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1435713446 14400
#      Tue Jun 30 21:17:26 2015 -0400
# Node ID 6e20445b1da8baefbb48bae7af20dfcb2699c9ce
# Parent  e96033df31a3e45b1a0eecd793725c6aa9be7c14
revset: fix a crash with 'p1(wdir())'

The crash was "TypeError: expected string or Unicode object, NoneType found"
down in revlog.parentrevs().

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1450,7 +1450,10 @@
     ps = set()
     cl = repo.changelog
     for r in getset(repo, fullreposet(repo), x):
-        ps.add(cl.parentrevs(r)[0])
+        if r is None:
+            ps.update([repo[r].parents()[0].rev()])
+        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 optimisations from the fact this is a baseset.
diff --git a/tests/test-merge-default.t b/tests/test-merge-default.t
--- a/tests/test-merge-default.t
+++ b/tests/test-merge-default.t
@@ -66,6 +66,14 @@
   user:        test
   date:        * (glob)
   
+  $ hg log -r 'p1(wdir())'
+  changeset:   4:f25cbe84d8b3
+  tag:         tip
+  parent:      1:1846eede8b68
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     e
+  
   $ hg commit -mm1
 
 Should succeed - 2 heads:


More information about the Mercurial-devel mailing list