strip: remove -b/--backup codepaths
cset
ba3bc6474bbf has removed this option. This commit just tidies the
code that was associated to it. It also fixes the internal calls to
the strip() function.
Before this change, any function that thought it would want as a final
safety to keep a partial backup bundle (bundling changes not linearly
related to the current change being stripped), had to explicitly pass
a backup="strip" option. With this change, these backups are always
kept in case of an exception and always removed if there is no
exception. Only full backups can be specified with backup=True or no
full backups with backup=False.
--- a/hgext/mq.py Thu Aug 07 12:51:45 2014 -0400
+++ b/hgext/mq.py Thu Jul 24 15:06:08 2014 -0400
@@ -621,7 +621,7 @@
# apply failed, strip away that rev and merge.
hg.clean(repo, head)
- strip(self.ui, repo, [n], update=False, backup='strip')
+ strip(self.ui, repo, [n], update=False, backup=False)
ctx = repo[rev]
ret = hg.merge(repo, rev)
@@ -1463,7 +1463,7 @@
for patch in reversed(self.applied[start:end]):
self.ui.status(_("popping %s\n") % patch.name)
del self.applied[start:end]
- strip(self.ui, repo, [rev], update=False, backup='strip')
+ strip(self.ui, repo, [rev], update=False, backup=False)
for s, state in repo['.'].substate.items():
repo['.'].sub(s).get(state)
if self.applied:
@@ -1653,7 +1653,7 @@
repo.setparents(*cparents)
self.applied.pop()
self.applieddirty = True
- strip(self.ui, repo, [top], update=False, backup='strip')
+ strip(self.ui, repo, [top], update=False, backup=False)
except: # re-raises
repo.dirstate.invalidate()
raise
@@ -1851,7 +1851,7 @@
update = True
else:
update = False
- strip(self.ui, repo, [rev], update=update, backup='strip')
+ strip(self.ui, repo, [rev], update=update, backup=False)
if qpp:
self.ui.warn(_("saved queue repository parents: %s %s\n") %
(short(qpp[0]), short(qpp[1])))
--- a/hgext/shelve.py Thu Aug 07 12:51:45 2014 -0400
+++ b/hgext/shelve.py Thu Jul 24 15:06:08 2014 -0400
@@ -391,7 +391,7 @@
mergefiles(ui, repo, state.wctx, state.pendingctx)
- repair.strip(ui, repo, state.stripnodes, backup='none', topic='shelve')
+ repair.strip(ui, repo, state.stripnodes, backup=False, topic='shelve')
shelvedstate.clear(repo)
ui.warn(_("unshelve of '%s' aborted\n") % state.name)
finally:
@@ -460,7 +460,7 @@
mergefiles(ui, repo, state.wctx, shelvectx)
state.stripnodes.append(shelvectx.node())
- repair.strip(ui, repo, state.stripnodes, backup='none', topic='shelve')
+ repair.strip(ui, repo, state.stripnodes, backup=False, topic='shelve')
shelvedstate.clear(repo)
unshelvecleanup(ui, repo, state.name, opts)
ui.status(_("unshelve of '%s' complete\n") % state.name)
--- a/hgext/strip.py Thu Aug 07 12:51:45 2014 -0400
+++ b/hgext/strip.py Thu Jul 24 15:06:08 2014 -0400
@@ -42,7 +42,7 @@
raise util.Abort(_("local changed subrepos found" + excsuffix))
return m, a, r, d
-def strip(ui, repo, revs, update=True, backup="all", force=None, bookmark=None):
+def strip(ui, repo, revs, update=True, backup=True, force=None, bookmark=None):
wlock = lock = None
try:
wlock = repo.wlock()
@@ -114,11 +114,9 @@
Return 0 on success.
"""
- backup = 'all'
- if opts.get('backup'):
- backup = 'strip'
- elif opts.get('no_backup') or opts.get('nobackup'):
- backup = 'none'
+ backup = True
+ if opts.get('no_backup') or opts.get('nobackup'):
+ backup = False
cl = repo.changelog
revs = list(revs) + opts.get('rev')
--- a/mercurial/repair.py Thu Aug 07 12:51:45 2014 -0400
+++ b/mercurial/repair.py Thu Jul 24 15:06:08 2014 -0400
@@ -47,7 +47,13 @@
return s
-def strip(ui, repo, nodelist, backup="all", topic='backup'):
+def strip(ui, repo, nodelist, backup=True, topic='backup'):
+
+ # Simple way to maintain backwards compatibility for this
+ # argument.
+ if backup in ['none', 'strip']:
+ backup = False
+
repo = repo.unfiltered()
repo.destroying()
@@ -58,8 +64,6 @@
striplist = [cl.rev(node) for node in nodelist]
striprev = min(striplist)
- keeppartialbundle = backup == 'strip'
-
# Some revisions with rev > striprev may not be descendants of striprev.
# We have to find these revisions and put them in a bundle, so that
# we can restore them after the truncations.
@@ -109,7 +113,7 @@
# create a changegroup for all the branches we need to keep
backupfile = None
vfs = repo.vfs
- if backup == "all":
+ if backup:
backupfile = _bundle(repo, stripbases, cl.heads(), node, topic)
repo.ui.status(_("saved backup bundle to %s\n") %
vfs.join(backupfile))
@@ -118,7 +122,7 @@
if saveheads or savebases:
# do not compress partial bundle if we remove it from disk later
chgrpfile = _bundle(repo, savebases, saveheads, node, 'temp',
- compress=keeppartialbundle)
+ compress=False)
mfst = repo.manifest
@@ -156,8 +160,6 @@
if not repo.ui.verbose:
repo.ui.popbuffer()
f.close()
- if not keeppartialbundle:
- vfs.unlink(chgrpfile)
# remove undo files
for undovfs, undofile in repo.undofiles():
@@ -179,5 +181,9 @@
ui.warn(_("strip failed, partial bundle stored in '%s'\n")
% vfs.join(chgrpfile))
raise
+ else:
+ if saveheads or savebases:
+ # Remove partial backup only if there were no exceptions
+ vfs.unlink(chgrpfile)
repo.destroyed()