hgweb/annotate: handle binary files like hgweb/file
authorThomas Arendsen Hein <thomas@intevation.de>
Sun, 02 Mar 2008 23:32:13 +0100
changeset 6203 3a75fcc96dac
parent 6202 0ab0da2215d7
child 6204 f8a86ea7521b
hgweb/annotate: handle binary files like hgweb/file
mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py	Sun Mar 02 20:54:00 2008 +0100
+++ b/mercurial/hgweb/hgweb_mod.py	Sun Mar 02 23:32:13 2008 +0100
@@ -654,7 +654,13 @@
 
         def annotate(**map):
             last = None
-            lines = enumerate(fctx.annotate(follow=True, linenumber=True))
+            if util.binary(fctx.data()):
+                mt = (mimetypes.guess_type(fctx.path())[0]
+                      or 'application/octet-stream')
+                lines = enumerate([((fctx.filectx(fctx.filerev()), 1),
+                                    '(binary:%s)' % mt)])
+            else:
+                lines = enumerate(fctx.annotate(follow=True, linenumber=True))
             for lineno, ((f, targetline), l) in lines:
                 fnode = f.filenode()
                 name = self.repo.ui.shortuser(f.user())