copy: add -n/--dry-run option
authorVadim Gelfer <vadim.gelfer@gmail.com>
Fri, 09 Jun 2006 08:48:30 -0700
changeset 2413 c1ec81319870
parent 2412 e5cb39577b9f
child 2414 86e07466bcfc
copy: add -n/--dry-run option
mercurial/commands.py
--- a/mercurial/commands.py	Fri Jun 09 08:42:36 2006 -0700
+++ b/mercurial/commands.py	Fri Jun 09 08:48:30 2006 -0700
@@ -1172,9 +1172,10 @@
     if not copylist:
         raise util.Abort(_('no files to copy'))
 
-    for targetpath, srcs in copylist:
-        for origsrc, abssrc, relsrc, exact in srcs:
-            copy(origsrc, abssrc, relsrc, targetpath(abssrc), exact)
+    if not opts.get('dry_run'):
+        for targetpath, srcs in copylist:
+            for origsrc, abssrc, relsrc, exact in srcs:
+                copy(origsrc, abssrc, relsrc, targetpath(abssrc), exact)
 
     if errors:
         ui.warn(_('(consider using --after)\n'))
@@ -2882,7 +2883,8 @@
           ('f', 'force', None,
            _('forcibly copy over an existing managed file')),
           ('I', 'include', [], _('include names matching the given patterns')),
-          ('X', 'exclude', [], _('exclude names matching the given patterns'))],
+          ('X', 'exclude', [], _('exclude names matching the given patterns')),
+          ('n', 'dry-run', None, _('print what would be done'))],
          _('hg copy [OPTION]... [SOURCE]... DEST')),
     "debugancestor": (debugancestor, [], _('debugancestor INDEX REV1 REV2')),
     "debugcomplete":