Patchwork [3,of,4] histedit: mention histedit-last-edit.txt on abort

login
register
mail settings
Submitter timeless@mozdev.org
Date Dec. 2, 2015, 8:13 a.m.
Message ID <6c1a9a53f7c441b4ef68.1449044015@waste.org>
Download mbox | patch
Permalink /patch/11737/
State Accepted
Headers show

Comments

timeless@mozdev.org - Dec. 2, 2015, 8:13 a.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1449043656 0
#      Wed Dec 02 08:07:36 2015 +0000
# Node ID 6c1a9a53f7c441b4ef68b7e891249539c702b2ae
# Parent  97b0c60ab14023b65afdaa0563c8efbea6da66a8
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.
Augie Fackler - Dec. 2, 2015, 3:12 p.m.
On Wed, Dec 02, 2015 at 02:13:35AM -0600, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1449043656 0
> #      Wed Dec 02 08:07:36 2015 +0000
> # Node ID 6c1a9a53f7c441b4ef68b7e891249539c702b2ae
> # Parent  97b0c60ab14023b65afdaa0563c8efbea6da66a8
> histedit: mention histedit-last-edit.txt on abort

Queued patches 1,3,4 with a commit message tweak on 4 and
s/instructions/rules/ in this patch (to keep the noun consistent).

I'll respond to patch 2 now with some bikeshedding.

>
> 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.
>
> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -779,6 +779,10 @@
>          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 instructions saved to: .hg/histedit-last-edit.txt\n'))
> +        raise
>      finally:
>          release(state.lock, state.wlock)
>
> @@ -907,6 +911,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:
> diff --git a/tests/test-histedit-edit.t b/tests/test-histedit-edit.t
> --- a/tests/test-histedit-edit.t
> +++ b/tests/test-histedit-edit.t
> @@ -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 instructions 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
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -779,6 +779,10 @@ 
         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 instructions saved to: .hg/histedit-last-edit.txt\n'))
+        raise
     finally:
         release(state.lock, state.wlock)
 
@@ -907,6 +911,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:
diff --git a/tests/test-histedit-edit.t b/tests/test-histedit-edit.t
--- a/tests/test-histedit-edit.t
+++ b/tests/test-histedit-edit.t
@@ -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 instructions 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