changeset 2415:dec79ed61ee1

revert: add -n/--dry-run option
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Fri, 09 Jun 2006 09:06:40 -0700
parents 86e07466bcfc
children 04736f38d74f
files mercurial/commands.py
diffstat 1 files changed, 13 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Fri Jun 09 09:00:08 2006 -0700
+++ b/mercurial/commands.py	Fri Jun 09 09:06:40 2006 -0700
@@ -2417,8 +2417,9 @@
                 bakname = "%s.orig" % rel
                 ui.note(_('saving current version of %s as %s\n') %
                         (rel, bakname))
-                shutil.copyfile(rel, bakname)
-                shutil.copymode(rel, bakname)
+                if not opts.get('dry_run'):
+                    shutil.copyfile(rel, bakname)
+                    shutil.copymode(rel, bakname)
             if ui.verbose or not exact:
                 ui.status(xlist[1] % rel)
         for table, hitlist, misslist, backuphit, backupmiss in disptable:
@@ -2449,13 +2450,14 @@
                 else:
                     handle(remove, False)
 
-    repo.dirstate.forget(forget[0])
-    r = repo.update(node, False, True, update.has_key, False, wlock=wlock,
-                    show_stats=False)
-    repo.dirstate.update(add[0], 'a')
-    repo.dirstate.update(undelete[0], 'n')
-    repo.dirstate.update(remove[0], 'r')
-    return r
+    if not opts.get('dry_run'):
+        repo.dirstate.forget(forget[0])
+        r = repo.update(node, False, True, update.has_key, False, wlock=wlock,
+                        show_stats=False)
+        repo.dirstate.update(add[0], 'a')
+        repo.dirstate.update(undelete[0], 'n')
+        repo.dirstate.update(remove[0], 'r')
+        return r
 
 def rollback(ui, repo):
     """roll back the last transaction in this repository
@@ -3075,7 +3077,8 @@
          [('r', 'rev', '', _('revision to revert to')),
           ('', 'no-backup', None, _('do not save backup copies of files')),
           ('I', 'include', [], _('include names matching given patterns')),
-          ('X', 'exclude', [], _('exclude names matching given patterns'))],
+          ('X', 'exclude', [], _('exclude names matching given patterns')),
+          ('n', 'dry-run', None, _('print what would be done'))],
          _('hg revert [-r REV] [NAME]...')),
     "rollback": (rollback, [], _('hg rollback')),
     "root": (root, [], _('hg root')),