changeset 19849:e7fa36d2ad3a stable 2.7.2

rebase: catch RepoLookupError at restoring rebase state for summary Before this patch, "hg summary" may fail, when there is inconsistent rebase state: for example, the root of rebase destination revisions recorded in rebase state file is already stripped manually. Mercurial earlier than 2.7 allows users to do anything other than starting new rebase, even though current rebase is not finished or aborted yet. So, such inconsistent rebase states may be left and forgotten in repositories. This patch catches RepoLookupError at restoring rebase state for summary hook, and treat such state as "broken".
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Tue, 01 Oct 2013 00:35:07 +0900
parents 577f4c562d52
children fa72bd896a34
files hgext/rebase.py tests/test-rebase-abort.t
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Tue Oct 01 00:35:07 2013 +0900
+++ b/hgext/rebase.py	Tue Oct 01 00:35:07 2013 +0900
@@ -813,7 +813,13 @@
 def summaryhook(ui, repo):
     if not os.path.exists(repo.join('rebasestate')):
         return
-    state = restorestatus(repo)[2]
+    try:
+        state = restorestatus(repo)[2]
+    except error.RepoLookupError:
+        # i18n: column positioning for "hg summary"
+        msg = _('rebase: (use "hg rebase --abort" to clear broken state)\n')
+        ui.write(msg)
+        return
     numrebased = len([i for i in state.itervalues() if i != -1])
     # i18n: column positioning for "hg summary"
     ui.write(_('rebase: %s, %s (rebase --continue)\n') %
--- a/tests/test-rebase-abort.t	Tue Oct 01 00:35:07 2013 +0900
+++ b/tests/test-rebase-abort.t	Tue Oct 01 00:35:07 2013 +0900
@@ -95,6 +95,8 @@
   abort: cannot continue inconsistent rebase
   (use "hg rebase --abort" to clear borken state)
   [255]
+  $ hg summary | grep '^rebase: '
+  rebase: (use "hg rebase --abort" to clear broken state)
   $ hg rebase --abort
   rebase aborted (no revision is removed, only broken state is cleared)