diff mercurial/hgweb/hgweb_mod.py @ 6142:50a277e6ceae

merge backout
author Thomas Arendsen Hein <thomas@intevation.de>
date Mon, 18 Feb 2008 19:21:33 +0100
parents 90e5c82a3859 74406f50bd46
children b023915aa1bc
line wrap: on
line diff
--- a/mercurial/hgweb/hgweb_mod.py	Mon Feb 18 19:20:22 2008 +0100
+++ b/mercurial/hgweb/hgweb_mod.py	Mon Feb 18 19:21:33 2008 +0100
@@ -10,7 +10,8 @@
 from mercurial.node import *
 from mercurial import mdiff, ui, hg, util, archival, patch, hook
 from mercurial import revlog, templater, templatefilters
-from common import ErrorResponse, get_mtime, style_map, paritygen, get_contact
+from common import get_mtime, style_map, paritygen, countgen, get_contact
+from common import ErrorResponse
 from common import HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR
 from request import wsgirequest
 import webcommands, protocol
@@ -371,16 +372,26 @@
                        file=f,
                        filenode=hex(fn or nullid))
 
+        blockcount = countgen()
         def prettyprintlines(diff):
-            for l in diff.splitlines(1):
+            blockno = blockcount.next()
+            for lineno, l in enumerate(diff.splitlines(1)):
+                if blockno == 0:
+                    lineno = lineno + 1
+                else:
+                    lineno = "%d.%d" % (blockno, lineno + 1)
                 if l.startswith('+'):
-                    yield tmpl("difflineplus", line=l)
+                    ltype = "difflineplus"
                 elif l.startswith('-'):
-                    yield tmpl("difflineminus", line=l)
+                    ltype = "difflineminus"
                 elif l.startswith('@'):
-                    yield tmpl("difflineat", line=l)
+                    ltype = "difflineat"
                 else:
-                    yield tmpl("diffline", line=l)
+                    ltype = "diffline"
+                yield tmpl(ltype,
+                           line=l,
+                           lineid="l%s" % lineno,
+                           linenumber="% 8s" % lineno)
 
         r = self.repo
         c1 = r.changectx(node1)
@@ -466,7 +477,7 @@
             def revgen():
                 for i in xrange(cl.count() - 1, 0, -100):
                     l = []
-                    for j in xrange(max(0, i - 100), i):
+                    for j in xrange(max(0, i - 100), i + 1):
                         ctx = self.repo.changectx(j)
                         l.append(ctx)
                     l.reverse()
@@ -596,9 +607,10 @@
             text = '(binary:%s)' % mt
 
         def lines():
-            for l, t in enumerate(text.splitlines(1)):
+            for lineno, t in enumerate(text.splitlines(1)):
                 yield {"line": t,
-                       "linenumber": "% 6d" % (l + 1),
+                       "lineid": "l%d" % (lineno + 1),
+                       "linenumber": "% 6d" % (lineno + 1),
                        "parity": parity.next()}
 
         return tmpl("filerevision",
@@ -623,7 +635,8 @@
 
         def annotate(**map):
             last = None
-            for f, l in fctx.annotate(follow=True):
+            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())
 
@@ -635,7 +648,10 @@
                        "rev": f.rev(),
                        "author": name,
                        "file": f.path(),
-                       "line": l}
+                       "targetline": targetline,
+                       "line": l,
+                       "lineid": "l%d" % (lineno + 1),
+                       "linenumber": "% 6d" % (lineno + 1)}
 
         return tmpl("fileannotate",
                     file=f,