histedit: don't clobber working copy on --abort if not on histedit cset
Similar to
issue4009, 2.7 will force people to abort histedits before
doing interesting things. Without this fix, people with histedit
sessions they wandered away from before upgrading to 2.7 could clobber
their working copy for no reason.
--- a/hgext/histedit.py Thu Aug 01 17:54:12 2013 -0500
+++ b/hgext/histedit.py Thu Aug 01 19:55:02 2013 -0500
@@ -506,7 +506,14 @@
(parentctxnode, rules, keep, topmost, replacements) = readstate(repo)
mapping, tmpnodes, leafs, _ntm = processreplacement(repo, replacements)
ui.debug('restore wc to old parent %s\n' % node.short(topmost))
- hg.clean(repo, topmost)
+ # check whether we should update away
+ parentnodes = [c.node() for c in repo[None].parents()]
+ for n in leafs | set([parentctxnode]):
+ if n in parentnodes:
+ hg.clean(repo, topmost)
+ break
+ else:
+ pass
cleanupnode(ui, repo, 'created', tmpnodes)
cleanupnode(ui, repo, 'temp', leafs)
os.unlink(os.path.join(repo.path, 'histedit-state'))
--- a/tests/test-histedit-no-change.t Thu Aug 01 17:54:12 2013 -0500
+++ b/tests/test-histedit-no-change.t Thu Aug 01 19:55:02 2013 -0500
@@ -169,13 +169,34 @@
o 0 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b "a"
-abort editing session
+abort editing session, after first forcibly updating away
+ $ hg up 0
+ abort: histedit in progress
+ (use 'hg histedit --continue' or 'hg histedit --abort')
+ [255]
+ $ mv .hg/histedit-state .hg/histedit-state-ignore
+ $ hg up 0
+ 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
+ $ mv .hg/histedit-state-ignore .hg/histedit-state
+ $ hg sum
+ parent: 0:cb9a9f314b8b
+ a
+ branch: default
+ commit: 1 modified, 1 unknown (new branch head)
+ update: 6 new changesets (update)
+ hist: 2 remaining (histedit --continue)
+
$ hg histedit --abort 2>&1 | fixbundle
- 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ [1]
+
+modified files should survive the abort when we've moved away already
+ $ hg st
+ M e
+ ? edit.sh
$ graphlog "log after abort"
% log after abort
- @ 5 652413bf663ef2a641cab26574e46d5f5a64a55a "f"
+ o 5 652413bf663ef2a641cab26574e46d5f5a64a55a "f"
|
o 4 e860deea161a2f77de56603b340ebbb4536308ae "e"
|
@@ -185,7 +206,7 @@
|
o 1 d2ae7f538514cd87c17547b0de4cea71fe1af9fb "b"
|
- o 0 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b "a"
+ @ 0 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b "a"
$ cd ..