Fixes for annotate
authormpm@selenic.com
Sat, 23 Jul 2005 14:11:49 -0500
changeset 771 0de223012086
parent 770 b3820ce0e88a
child 772 f05deda58457
Fixes for annotate Handle files that aren't in the repo Handle empty files
mercurial/commands.py
--- a/mercurial/commands.py	Sat Jul 23 10:14:42 2005 -0500
+++ b/mercurial/commands.py	Sat Jul 23 14:11:49 2005 -0500
@@ -379,17 +379,23 @@
     change = repo.changelog.read(node)
     mmap = repo.manifest.read(change[0])
     for src, abs, rel in walk(repo, pats, opts):
+        if abs not in mmap:
+            ui.warn("warning: %s is not in the repository!\n" % rel)
+            continue
+
         lines = repo.file(abs).annotate(mmap[abs])
         pieces = []
 
         for o, f in opmap:
             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])
+                if l:
+                    m = max(map(len, l))
+                    pieces.append(["%*s" % (m, x) for x in l])
 
-        for p, l in zip(zip(*pieces), lines):
-            ui.write("%s: %s" % (" ".join(p), l[1]))
+        if pieces:
+            for p, l in zip(zip(*pieces), lines):
+                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"""