diff hgext/histedit.py @ 38548:7b57b1ed5c0f

histedit: add --no-backup option (issue5825) This option provides a functionality to not store a backup while aborting histedit in between. Also added tests for the same. Differential Revision: https://phab.mercurial-scm.org/D3872
author Sushil khanchi <sushilkhanchi97@gmail.com>
date Fri, 22 Jun 2018 23:53:43 +0530
parents 39db5a01cd53
children 88e6630dc8d0
line wrap: on
line diff
--- 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):