Fix field width for annotate
authormpm@selenic.com
Tue, 17 May 2005 01:22:50 -0800
changeset 80 5b7a444c794a
parent 79 837d473d54d5
child 81 17884f79d59d
Fix field width for annotate Add blame
hg
--- a/hg	Tue May 17 01:12:30 2005 -0800
+++ b/hg	Tue May 17 01:22:50 2005 -0800
@@ -212,7 +212,32 @@
         mmap = repo.manifest.read(change[0])
         for f in args:
             for n, l in repo.file(f).annotate(mmap[f]):
-                sys.stdout.write("%s: %s"%(n, l))
+                sys.stdout.write("% 6s:%s"%(n, l))
+
+elif cmd == "blame":
+    aoptions = {}
+    opts = [('r', 'revision', '', 'revision')]
+    args = fancyopts.fancyopts(args, opts, aoptions,
+                               'hg blame [-r id] [files]')
+    if args:
+        bcache = {}
+        node = repo.current
+        if aoptions['revision']:
+            node = repo.changelog.lookup(aoptions['revision'])
+        change = repo.changelog.read(node)
+        mmap = repo.manifest.read(change[0])
+        for f in args:
+            for n, l in repo.file(f).annotate(mmap[f]):
+                try:
+                    name = bcache[n]
+                except KeyError:
+                    cl = repo.changelog.read(repo.changelog.node(n))
+                    name = cl[1]
+                    f = name.find('@')
+                    if f >= 0:
+                        name = name[:f]
+                    bcache[n] = name
+                sys.stdout.write("% 10s:%s"%(name, l))
 
 elif cmd == "export":
     node = repo.lookup(args[0])