diff mercurial/commands.py @ 714:29fcd195e056

Some cleanups in commands.annotate(). -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Some cleanups in commands.annotate(). manifest hash: 9581ad3bb9ebc418e4772158c505e34b92496e92 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFC2K+nW7P1GVgWeRoRAr3VAKCGvKbhmG4yweZTgmxIgaZlmz16HQCdFupq BKcWfEn17Y1l6IDbGS0rDyI= =/fR/ -----END PGP SIGNATURE-----
author Thomas Arendsen Hein <thomas@intevation.de>
date Sat, 16 Jul 2005 07:56:39 +0100
parents b4f0fad0ea64
children 938dd667ca21
line wrap: on
line diff
--- a/mercurial/commands.py	Fri Jul 15 21:31:35 2005 +0100
+++ b/mercurial/commands.py	Sat Jul 16 07:56:39 2005 +0100
@@ -311,7 +311,7 @@
     repo.add(u)
     repo.remove(d)
 
-def annotate(u, repo, file1, *files, **ops):
+def annotate(ui, repo, file1, *files, **opts):
     """show changeset information per file line"""
     def getnode(rev):
         return hg.short(repo.changelog.node(rev))
@@ -333,12 +333,13 @@
 
     bcache = {}
     opmap = [['user', getname], ['number', str], ['changeset', getnode]]
-    if not ops['user'] and not ops['changeset']:
-        ops['number'] = 1
+    if not opts['user'] and not opts['changeset']:
+        opts['number'] = 1
 
-    node = repo.dirstate.parents()[0]
-    if ops['revision']:
-        node = repo.changelog.lookup(ops['revision'])
+    if opts['revision']:
+        node = repo.changelog.lookup(opts['revision'])
+    else:
+        node = repo.dirstate.parents()[0]
     change = repo.changelog.read(node)
     mmap = repo.manifest.read(change[0])
     for f in relpath(repo, (file1,) + files):
@@ -346,13 +347,13 @@
         pieces = []
 
         for o, f in opmap:
-            if ops[o]:
+            if opts[o]:
                 l = [f(n) for n, dummy in lines]
                 m = max(map(len, l))
                 pieces.append(["%*s" % (m, x) for x in l])
 
         for p, l in zip(zip(*pieces), lines):
-            u.write(" ".join(p) + ": " + l[1])
+            ui.write("%s: %s" % (" ".join(p), l[1]))
 
 def cat(ui, repo, file1, rev=None, **opts):
     """output the latest or given revision of a file"""