[PATCH 5 of 6] revset: fix a crash with 'wdir()^N'

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


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1435714709 14400
#      Tue Jun 30 21:38:29 2015 -0400
# Node ID e26c2caf800020627f58e45f799ce932c6aee761
# Parent  4a504f9bae9718664cc685397ff066e93c163327
revset: fix a crash with 'wdir()^N'

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
@@ -1552,9 +1552,15 @@
         if n == 0:
             ps.add(r)
         elif n == 1:
-            ps.add(cl.parentrevs(r)[0])
+            if r is None:
+                ps.add(repo[r].parents()[0].rev())
+            else:
+                ps.add(cl.parentrevs(r)[0])
         elif n == 2:
-            parents = cl.parentrevs(r)
+            if r is None:
+                parents = [p.rev() for p in repo[r].parents()]
+            else:
+                parents = cl.parentrevs(r)
             if len(parents) > 1:
                 ps.add(parents[1])
     return subset & ps
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
@@ -74,14 +74,34 @@
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     e
   
+  $ hg log -r 'wdir()^1'
+  changeset:   4:f25cbe84d8b3
+  tag:         tip
+  parent:      1:1846eede8b68
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     e
+  
   $ hg log -r 'p2(wdir())'
   changeset:   2:2d95304fed5d
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     c
   
+  $ hg log -r 'wdir()^2'
+  changeset:   2:2d95304fed5d
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     c
+  
   $ hg commit -mm1
 
+  $ hg log -r 'wdir()^2'
+  $ hg log -r 'wdir()^0'
+  changeset:   5:a431fabd6039+
+  user:        test
+  date:        * (glob)
+  
 Should succeed - 2 heads:
 
   $ hg merge -P


More information about the Mercurial-devel mailing list