discovery: prevent crash caused by prune marker having no parent data stable
authorYuya Nishihara <yuya@tcha.org>
Wed, 19 Apr 2017 23:10:05 +0900
branchstable
changeset 32095 c52728b383b4
parent 32094 2de67783dd31
child 32096 726121fa86e1
discovery: prevent crash caused by prune marker having no parent data If a marker has no parent information, parents field is set to None, which caused TypeError. I think this shouldn't normally happen, but somehow I have such marker in my repo.
mercurial/discovery.py
tests/test-obsolete-checkheads.t
--- a/mercurial/discovery.py	Mon May 01 15:40:41 2017 +0200
+++ b/mercurial/discovery.py	Wed Apr 19 23:10:05 2017 +0900
@@ -511,7 +511,7 @@
         for m in markers:
             nexts = m[1] # successors
             if not nexts: # this is a prune marker
-                nexts = m[5] # parents
+                nexts = m[5] or () # parents
             for n in nexts:
                 if n not in seen:
                     seen.add(n)
--- a/tests/test-obsolete-checkheads.t	Mon May 01 15:40:41 2017 +0200
+++ b/tests/test-obsolete-checkheads.t	Wed Apr 19 23:10:05 2017 +0900
@@ -281,3 +281,32 @@
   adding manifests
   adding file changes
   added 1 changesets with 1 changes to 1 files (+1 heads)
+
+Old head is pruned without parent data and new unrelated head added
+===================================================================
+
+setup
+
+  $ cd ..
+  $ rm -R remote local
+  $ cp -R backup1 remote
+  $ hg clone remote local -qr c70b08862e08
+  $ cd local
+  $ hg up -q '.^'
+  $ mkcommit new-unrelated
+  created new head
+  $ hg debugobsolete `getid old`
+  $ hg log -G --hidden
+  @  350a93b716be (draft) add new-unrelated
+  |
+  | x  c70b08862e08 (draft) add old
+  |/
+  o  b4952fcf48cf (public) add base
+  
+
+  $ hg push
+  pushing to $TESTTMP/remote (glob)
+  searching for changes
+  abort: push creates new remote head 350a93b716be!
+  (merge or see 'hg help push' for details about pushing new heads)
+  [255]