--- a/hgext/histedit.py Sat Jun 30 18:55:04 2018 -0700
+++ b/hgext/histedit.py Fri Jun 22 23:53:43 2018 +0530
@@ -925,6 +925,7 @@
_("don't strip old nodes after edit is complete")),
('', 'abort', False, _('abort an edit in progress')),
('o', 'outgoing', False, _('changesets not found in destination')),
+ ('', 'no-backup', False, _('no backup')),
('f', 'force', False,
_('force outgoing even for unrelated repositories')),
('r', 'rev', [], _('first revision to be edited'), _('REV'))] +
@@ -1110,6 +1111,7 @@
fm.startitem()
goal = _getgoal(opts)
revs = opts.get('rev', [])
+ nobackup = opts.get('no_backup')
rules = opts.get('commands', '')
state.keep = opts.get('keep', False)
@@ -1123,7 +1125,7 @@
_edithisteditplan(ui, repo, state, rules)
return
elif goal == goalabort:
- _aborthistedit(ui, repo, state)
+ _aborthistedit(ui, repo, state, nobackup=nobackup)
return
else:
# goal == goalnew
@@ -1221,7 +1223,7 @@
if repo.vfs.exists('histedit-last-edit.txt'):
repo.vfs.unlink('histedit-last-edit.txt')
-def _aborthistedit(ui, repo, state):
+def _aborthistedit(ui, repo, state, nobackup=False):
try:
state.read()
__, leafs, tmpnodes, __ = processreplacement(state)
@@ -1243,8 +1245,8 @@
if repo.unfiltered().revs('parents() and (%n or %ln::)',
state.parentctxnode, leafs | tmpnodes):
hg.clean(repo, state.topmost, show_stats=True, quietempty=True)
- cleanupnode(ui, repo, tmpnodes)
- cleanupnode(ui, repo, leafs)
+ cleanupnode(ui, repo, tmpnodes, nobackup=nobackup)
+ cleanupnode(ui, repo, leafs, nobackup=nobackup)
except Exception:
if state.inprogress():
ui.warn(_('warning: encountered an exception during histedit '
@@ -1601,7 +1603,7 @@
changes.append((name, newtopmost))
marks.applychanges(repo, tr, changes)
-def cleanupnode(ui, repo, nodes):
+def cleanupnode(ui, repo, nodes, nobackup=False):
"""strip a group of nodes from the repository
The set of node to strip may contains unknown nodes."""
@@ -1616,7 +1618,8 @@
nodes = sorted(n for n in nodes if n in nm)
roots = [c.node() for c in repo.set("roots(%ln)", nodes)]
if roots:
- repair.strip(ui, repo, roots)
+ backup = not nobackup
+ repair.strip(ui, repo, roots, backup=backup)
def stripwrapper(orig, ui, repo, nodelist, *args, **kwargs):
if isinstance(nodelist, str):
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-histedit-no-backup.t Fri Jun 22 23:53:43 2018 +0530
@@ -0,0 +1,95 @@
+ $ . "$TESTDIR/histedit-helpers.sh"
+
+Enable extension used by this test
+ $ cat >>$HGRCPATH <<EOF
+ > [extensions]
+ > histedit=
+ > EOF
+
+Repo setup:
+ $ hg init foo
+ $ cd foo
+ $ echo first>file
+ $ hg ci -qAm one
+ $ echo second>>file
+ $ hg ci -m two
+ $ echo third>>file
+ $ hg ci -m three
+ $ echo forth>>file
+ $ hg ci -m four
+ $ hg log -G --style compact
+ @ 3[tip] 7d5187087c79 1970-01-01 00:00 +0000 test
+ | four
+ |
+ o 2 80d23dfa866d 1970-01-01 00:00 +0000 test
+ | three
+ |
+ o 1 6153eb23e623 1970-01-01 00:00 +0000 test
+ | two
+ |
+ o 0 36b4bdd91f5b 1970-01-01 00:00 +0000 test
+ one
+
+Check when --no-backup is not passed
+ $ hg histedit -r '36b4bdd91f5b' --commands - << EOF
+ > pick 36b4bdd91f5b 0 one
+ > pick 6153eb23e623 1 two
+ > roll 80d23dfa866d 2 three
+ > edit 7d5187087c79 3 four
+ > EOF
+ merging file
+ Editing (7d5187087c79), you may commit or record as needed now.
+ (hg histedit --continue to resume)
+ [1]
+
+ $ hg histedit --abort
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ saved backup bundle to $TESTTMP/foo/.hg/strip-backup/1d8f701c7b35-cf7be322-backup.hg
+ saved backup bundle to $TESTTMP/foo/.hg/strip-backup/5c0056670bce-b54b65d0-backup.hg
+
+ $ hg st
+ $ hg diff
+ $ hg log -G --style compact
+ @ 3[tip] 7d5187087c79 1970-01-01 00:00 +0000 test
+ | four
+ |
+ o 2 80d23dfa866d 1970-01-01 00:00 +0000 test
+ | three
+ |
+ o 1 6153eb23e623 1970-01-01 00:00 +0000 test
+ | two
+ |
+ o 0 36b4bdd91f5b 1970-01-01 00:00 +0000 test
+ one
+
+
+Check when --no-backup is passed
+ $ hg histedit -r '36b4bdd91f5b' --commands - << EOF
+ > pick 36b4bdd91f5b 0 one
+ > pick 6153eb23e623 1 two
+ > roll 80d23dfa866d 2 three
+ > edit 7d5187087c79 3 four
+ > EOF
+ merging file
+ Editing (7d5187087c79), you may commit or record as needed now.
+ (hg histedit --continue to resume)
+ [1]
+
+ $ hg histedit --abort --no-backup
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+ $ hg st
+ $ hg diff
+ $ hg log -G --style compact
+ @ 3[tip] 7d5187087c79 1970-01-01 00:00 +0000 test
+ | four
+ |
+ o 2 80d23dfa866d 1970-01-01 00:00 +0000 test
+ | three
+ |
+ o 1 6153eb23e623 1970-01-01 00:00 +0000 test
+ | two
+ |
+ o 0 36b4bdd91f5b 1970-01-01 00:00 +0000 test
+ one
+