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

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


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1435715342 14400
#      Tue Jun 30 21:49:02 2015 -0400
# Node ID c3aecbbe50596e54402e4bd98931d33f1b2d5d01
# Parent  e26c2caf800020627f58e45f799ce932c6aee761
revset: fix a crash with 'roots(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
@@ -1794,8 +1794,12 @@
     Changesets in set with no parent changeset in set.
     """
     s = getset(repo, fullreposet(repo), x)
-    parents = repo.changelog.parentrevs
+    parentrevs = repo.changelog.parentrevs
     def filter(r):
+        parents = parentrevs
+        if r is None:
+            parents = lambda r: [p.rev() for p in repo[r].parents()]
+
         for p in parents(r):
             if 0 <= p and p in s:
                 return False
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
@@ -102,6 +102,11 @@
   user:        test
   date:        * (glob)
   
+  $ hg log -r 'roots(wdir())'
+  changeset:   5:a431fabd6039+
+  user:        test
+  date:        * (glob)
+  
 Should succeed - 2 heads:
 
   $ hg merge -P


More information about the Mercurial-devel mailing list