# HG changeset patch # User timeless # Date 2015-12-02 08:07:36 # Node ID 3028ea0aff468e55eac25606490e99a4a354869c # Parent 4cff4c38c5cc9bfd97b327cdf5834163187a231c 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. diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -829,6 +829,11 @@ def histedit(ui, repo, *freeargs, **opts 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 @@ def _histedit(ui, repo, state, *freeargs 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 @@ Attempting to fold a change into a publi 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