diff mercurial/commands.py @ 2958:ff3ea21a981a

addremove: add -s/--similarity option progress on issue 295.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Fri, 18 Aug 2006 22:13:58 -0700
parents 6dddcba7596a
children a8546e40070a
line wrap: on
line diff
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -658,8 +658,17 @@ def addremove(ui, repo, *pats, **opts):
 
     New files are ignored if they match any of the patterns in .hgignore. As
     with add, these changes take effect at the next commit.
+
+    Use the -s option to detect renamed files.  With a parameter > 0,
+    this compares every removed file with every added file and records
+    those similar enough as renames.  This option takes a percentage
+    between 0 (disabled) and 100 (files must be identical) as its
+    parameter.  Detecting renamed files this way can be expensive.
     """
-    return cmdutil.addremove(repo, pats, opts)
+    sim = float(opts.get('similarity') or 0)
+    if sim < 0 or sim > 100:
+        raise util.Abort(_('similarity must be between 0 and 100'))
+    return cmdutil.addremove(repo, pats, opts, similarity=sim/100.)
 
 def annotate(ui, repo, *pats, **opts):
     """show changeset information per file line
@@ -2747,7 +2756,10 @@ table = {
         (addremove,
          [('I', 'include', [], _('include names matching the given patterns')),
           ('X', 'exclude', [], _('exclude names matching the given patterns')),
-          ('n', 'dry-run', None, _('do not perform actions, just print output'))],
+          ('n', 'dry-run', None,
+           _('do not perform actions, just print output')),
+          ('s', 'similarity', '',
+           _('guess renamed files by similarity (0<=s<=1)'))],
          _('hg addremove [OPTION]... [FILE]...')),
     "^annotate":
         (annotate,