##// END OF EJS Templates
revert: add -n/--dry-run option
Vadim Gelfer -
r2415:dec79ed6 default
parent child Browse files
Show More
@@ -2417,8 +2417,9 b' def revert(ui, repo, *pats, **opts):'
2417 bakname = "%s.orig" % rel
2417 bakname = "%s.orig" % rel
2418 ui.note(_('saving current version of %s as %s\n') %
2418 ui.note(_('saving current version of %s as %s\n') %
2419 (rel, bakname))
2419 (rel, bakname))
2420 shutil.copyfile(rel, bakname)
2420 if not opts.get('dry_run'):
2421 shutil.copymode(rel, bakname)
2421 shutil.copyfile(rel, bakname)
2422 shutil.copymode(rel, bakname)
2422 if ui.verbose or not exact:
2423 if ui.verbose or not exact:
2423 ui.status(xlist[1] % rel)
2424 ui.status(xlist[1] % rel)
2424 for table, hitlist, misslist, backuphit, backupmiss in disptable:
2425 for table, hitlist, misslist, backuphit, backupmiss in disptable:
@@ -2449,13 +2450,14 b' def revert(ui, repo, *pats, **opts):'
2449 else:
2450 else:
2450 handle(remove, False)
2451 handle(remove, False)
2451
2452
2452 repo.dirstate.forget(forget[0])
2453 if not opts.get('dry_run'):
2453 r = repo.update(node, False, True, update.has_key, False, wlock=wlock,
2454 repo.dirstate.forget(forget[0])
2454 show_stats=False)
2455 r = repo.update(node, False, True, update.has_key, False, wlock=wlock,
2455 repo.dirstate.update(add[0], 'a')
2456 show_stats=False)
2456 repo.dirstate.update(undelete[0], 'n')
2457 repo.dirstate.update(add[0], 'a')
2457 repo.dirstate.update(remove[0], 'r')
2458 repo.dirstate.update(undelete[0], 'n')
2458 return r
2459 repo.dirstate.update(remove[0], 'r')
2460 return r
2459
2461
2460 def rollback(ui, repo):
2462 def rollback(ui, repo):
2461 """roll back the last transaction in this repository
2463 """roll back the last transaction in this repository
@@ -3075,7 +3077,8 b' table = {'
3075 [('r', 'rev', '', _('revision to revert to')),
3077 [('r', 'rev', '', _('revision to revert to')),
3076 ('', 'no-backup', None, _('do not save backup copies of files')),
3078 ('', 'no-backup', None, _('do not save backup copies of files')),
3077 ('I', 'include', [], _('include names matching given patterns')),
3079 ('I', 'include', [], _('include names matching given patterns')),
3078 ('X', 'exclude', [], _('exclude names matching given patterns'))],
3080 ('X', 'exclude', [], _('exclude names matching given patterns')),
3081 ('n', 'dry-run', None, _('print what would be done'))],
3079 _('hg revert [-r REV] [NAME]...')),
3082 _('hg revert [-r REV] [NAME]...')),
3080 "rollback": (rollback, [], _('hg rollback')),
3083 "rollback": (rollback, [], _('hg rollback')),
3081 "root": (root, [], _('hg root')),
3084 "root": (root, [], _('hg root')),
General Comments 0
You need to be logged in to leave comments. Login now