changeset 20327:46c2331fc750 stable

rebase: abort cleanly when we encounter a damaged rebasestate (issue4155)
author Matt Mackall <mpm@selenic.com>
date Thu, 30 Jan 2014 13:56:56 -0600
parents 82cbaf025b98
children 03d345da0579
files hgext/rebase.py tests/test-rebase-abort.t
diffstat 2 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Thu Jan 30 17:09:13 2014 +0900
+++ b/hgext/rebase.py	Thu Jan 30 13:56:56 2014 -0600
@@ -658,6 +658,7 @@
 def restorestatus(repo):
     'Restore a previously stored status'
     try:
+        keepbranches = None
         target = None
         collapse = False
         external = nullrev
@@ -687,6 +688,10 @@
                     state[repo[oldrev].rev()] = int(newrev)
                 else:
                     state[repo[oldrev].rev()] = repo[newrev].rev()
+
+        if keepbranches is None:
+            raise util.Abort(_('.hg/rebasestate is incomplete'))
+
         skipped = set()
         # recompute the set of skipped revs
         if not collapse:
--- a/tests/test-rebase-abort.t	Thu Jan 30 17:09:13 2014 +0900
+++ b/tests/test-rebase-abort.t	Thu Jan 30 13:56:56 2014 -0600
@@ -13,6 +13,16 @@
   $ hg init a
   $ cd a
 
+  $ touch .hg/rebasestate
+  $ hg sum
+  parent: -1:000000000000 tip (empty repository)
+  branch: default
+  commit: (clean)
+  update: (current)
+  abort: .hg/rebasestate is incomplete
+  [255]
+  $ rm .hg/rebasestate
+
   $ echo c1 > common
   $ hg add common
   $ hg ci -m C1