commands: annotate follows by default, separate -f/--file option
authorDirkjan Ochtman <dirkjan@ochtman.nl>
Sun, 07 Feb 2010 14:51:52 +0100
changeset 10369 98a0421b9e52
parent 10368 f05e0d54f424
child 10370 c050b7e4e778
commands: annotate follows by default, separate -f/--file option
mercurial/commands.py
tests/test-annotate
tests/test-annotate.out
tests/test-debugcomplete.out
--- a/mercurial/commands.py	Sun Feb 07 14:43:21 2010 +0100
+++ b/mercurial/commands.py	Sun Feb 07 14:51:52 2010 +0100
@@ -95,11 +95,11 @@
              ('number', lambda x: str(x[0].rev())),
              ('changeset', lambda x: short(x[0].node())),
              ('date', getdate),
-             ('follow', lambda x: x[0].path()),
+             ('file', lambda x: x[0].path()),
             ]
 
     if (not opts.get('user') and not opts.get('changeset')
-        and not opts.get('date') and not opts.get('follow')):
+        and not opts.get('date') and not opts.get('file')):
         opts['number'] = 1
 
     linenumber = opts.get('line_number') is not None
@@ -112,16 +112,15 @@
         funcmap[-1] = lambda x: "%s:%s" % (lastfunc(x), x[1])
 
     ctx = repo[opts.get('rev')]
-
     m = cmdutil.match(repo, pats, opts)
+    follow = not opts.get('no_follow')
     for abs in ctx.walk(m):
         fctx = ctx[abs]
         if not opts.get('text') and util.binary(fctx.data()):
             ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
             continue
 
-        lines = fctx.annotate(follow=opts.get('follow'),
-                              linenumber=linenumber)
+        lines = fctx.annotate(follow=follow, linenumber=linenumber)
         pieces = []
 
         for f in funcmap:
@@ -3360,9 +3359,11 @@
     "^annotate|blame":
         (annotate,
          [('r', 'rev', '', _('annotate the specified revision')),
-          ('f', 'follow', None, _('follow file copies and renames')),
+          ('', 'follow', None, _('follow copies and renames (DEPRECATED)')),
+          ('', 'no-follow', None, _("don't follow copies and renames")),
           ('a', 'text', None, _('treat all files as text')),
           ('u', 'user', None, _('list the author (long with -v)')),
+          ('f', 'file', None, _('list the filename')),
           ('d', 'date', None, _('list the date (short with -q)')),
           ('n', 'number', None, _('list the revision number (default)')),
           ('c', 'changeset', None, _('list the changeset')),
--- a/tests/test-annotate	Sun Feb 07 14:43:21 2010 +0100
+++ b/tests/test-annotate	Sun Feb 07 14:51:52 2010 +0100
@@ -49,6 +49,8 @@
 
 echo % annotate -n b
 hg annotate -n b
+echo % annotate --no-follow b
+hg annotate --no-follow b
 echo % annotate -nl b
 hg annotate -nl b
 echo % annotate -nf b
--- a/tests/test-annotate.out	Sun Feb 07 14:43:21 2010 +0100
+++ b/tests/test-annotate.out	Sun Feb 07 14:51:52 2010 +0100
@@ -18,6 +18,13 @@
 % annotate -cdnul
 nobody 0 8435f90966e4 Thu Jan 01 00:00:01 1970 +0000:1: a
 % annotate -n b
+0: a
+1: a
+1: a
+3: b4
+3: b5
+3: b6
+% annotate --no-follow b
 2: a
 2: a
 2: a
@@ -25,9 +32,9 @@
 3: b5
 3: b6
 % annotate -nl b
-2:1: a
-2:2: a
-2:3: a
+0:1: a
+1:2: a
+1:3: a
 3:4: b4
 3:5: b5
 3:6: b6
@@ -95,4 +102,4 @@
 1:3: a
 % generate ABA rename configuration
 % annotate after ABA with follow
-foo: foo
+8: foo
--- a/tests/test-debugcomplete.out	Sun Feb 07 14:43:21 2010 +0100
+++ b/tests/test-debugcomplete.out	Sun Feb 07 14:51:52 2010 +0100
@@ -164,7 +164,7 @@
 
 % Show all commands + options
 add: include, exclude, dry-run
-annotate: rev, follow, text, user, date, number, changeset, line-number, include, exclude
+annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, include, exclude
 clone: noupdate, updaterev, rev, pull, uncompressed, ssh, remotecmd
 commit: addremove, close-branch, include, exclude, message, logfile, date, user
 diff: rev, change, text, git, nodates, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, stat, include, exclude