@@ -2621,13 +2621,14 @@ def revert(ui, repo, ctx, parents, *pats
}
# should we do a backup?
backup = 2
+ check = 1
discard = 0
if opts.get('no_backup'):
- backup = 0
+ check = backup = discard
disptable = (
# dispatch table:
# file state
# action
@@ -2647,15 +2648,15 @@ def revert(ui, repo, ctx, parents, *pats
# Added since target but file is missing in working directory
(deladded, actions['drop'], discard),
# Removed since target, before working copy parent
(removed, actions['add'], discard),
# Same as `removed` but an unknown file exists at the same path
- (removunk, actions['add'], backup),
+ (removunk, actions['add'], check),
# Removed since targe, marked as such in working copy parent
(dsremoved, actions['undelete'], discard),
# Same as `dsremoved` but an unknown file exists at the same path
- (dsremovunk, actions['undelete'], backup),
+ (dsremovunk, actions['undelete'], check),
## the following sets does not result in any file changes
# File with no modification
(clean, actions['noop'], discard),
# Existing file, not tracked anywhere
(unknown, actions['unknown'], discard),
@@ -2674,16 +2675,16 @@ def revert(ui, repo, ctx, parents, *pats
for table, (xlist, msg), dobackup in disptable:
if abs not in table:
continue
if xlist is not None:
xlist.append(abs)
- if (dobackup and wctx[abs].cmp(ctx[abs])):
- bakname = "%s.orig" % rel
- ui.note(_('saving current version of %s as %s\n') %
- (rel, bakname))
- if not opts.get('dry_run'):
- util.rename(target, bakname)
+ if dobackup and (dobackup >= 2 or wctx[abs].cmp(ctx[abs])):
+ bakname = "%s.orig" % rel
+ ui.note(_('saving current version of %s as %s\n') %
+ (rel, bakname))
+ if not opts.get('dry_run'):
+ util.rename(target, bakname)
if ui.verbose or not exact:
if not isinstance(msg, basestring):
msg = msg(abs)
ui.status(msg % rel)
elif exact: