histedit: mention histedit-last-edit.txt on abort
authortimeless <timeless@mozdev.org>
Wed, 02 Dec 2015 08:07:36 +0000
changeset 27171 3028ea0aff46
parent 27170 4cff4c38c5cc
child 27172 4d61c847e06c
histedit: mention histedit-last-edit.txt on abort Users may spend a lot of effort writing histedit rules, getting an abort without being told they can recover their work is very frustrating. Avoid that by telling them where to find their work.
hgext/histedit.py
tests/test-histedit-edit.t
--- a/hgext/histedit.py	Wed Dec 02 07:40:42 2015 +0000
+++ b/hgext/histedit.py	Wed Dec 02 08:07:36 2015 +0000
@@ -829,6 +829,11 @@
         state.wlock = repo.wlock()
         state.lock = repo.lock()
         _histedit(ui, repo, state, *freeargs, **opts)
+    except error.Abort:
+        if repo.vfs.exists('histedit-last-edit.txt'):
+            ui.warn(_('warning: histedit rules saved '
+                      'to: .hg/histedit-last-edit.txt\n'))
+        raise
     finally:
         release(state.lock, state.wlock)
 
@@ -957,6 +962,8 @@
         cmdutil.checkunfinished(repo)
         cmdutil.bailifchanged(repo)
 
+        if repo.vfs.exists('histedit-last-edit.txt'):
+            repo.vfs.unlink('histedit-last-edit.txt')
         topmost, empty = repo.dirstate.parents()
         if outg:
             if freeargs:
--- a/tests/test-histedit-edit.t	Wed Dec 02 07:40:42 2015 +0000
+++ b/tests/test-histedit-edit.t	Wed Dec 02 08:07:36 2015 +0000
@@ -460,8 +460,24 @@
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   reverting a
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  warning: histedit rules saved to: .hg/histedit-last-edit.txt
   abort: cannot fold into public change 18aa70c8ad22
   [255]
+  $ cat .hg/histedit-last-edit.txt
+  fold 0012be4a27ea 2 extend a
+  
+  # Edit history between 0012be4a27ea and 0012be4a27ea
+  #
+  # Commits are listed from least to most recent
+  #
+  # Commands:
+  #  p, fold = use commit
+  #  e, edit = use commit, but stop for amending
+  #  f, fold = use commit, but combine it with the one above
+  #  r, roll = like fold, but discard this commit's description
+  #  d, drop = remove commit from history
+  #  m, mess = edit commit message without changing commit content
+  #
 TODO: this abort shouldn't be required, but it is for now to leave the repo in
 a clean state.
   $ hg histedit --abort