changeset 3408:4e0c08f019b8

merge with main
author Thomas Arendsen Hein <thomas@intevation.de>
date Mon, 16 Oct 2006 09:23:26 +0200
parents 03e7e8958a27 (diff) d2b55e3c4e25 (current diff)
children 1ae738bacf74
files
diffstat 8 files changed, 74 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Sun Oct 15 16:18:09 2006 -0500
+++ b/mercurial/context.py	Mon Oct 16 09:23:26 2006 +0200
@@ -254,10 +254,16 @@
 
             return [ getctx(p, n) for p, n in pl if n != -1 ]
 
+        # use linkrev to find the first changeset where self appeared
+        if self.rev() != self._filelog.linkrev(self._filenode):
+            base = self.filectx(self.filerev())
+        else:
+            base = self
+
         # find all ancestors
-        needed = {self: 1}
-        visit = [self]
-        files = [self._path]
+        needed = {base: 1}
+        visit = [base]
+        files = [base._path]
         while visit:
             f = visit.pop(0)
             for p in parents(f):
--- a/mercurial/hgweb/hgweb_mod.py	Sun Oct 15 16:18:09 2006 -0500
+++ b/mercurial/hgweb/hgweb_mod.py	Mon Oct 16 09:23:26 2006 +0200
@@ -28,6 +28,41 @@
         return "/"
     return up + "/"
 
+def revnavgen(pos, pagelen, limit):
+    def seq(factor, limit=None):
+        if limit:
+            yield limit
+            if limit >= 20 and limit <= 40:
+                yield 50
+        else:
+            yield 1 * factor
+            yield 3 * factor
+        for f in seq(factor * 10):
+            yield f
+
+    def nav(**map):
+        l = []
+        last = 0
+        for f in seq(1, pagelen):
+            if f < pagelen or f <= last:
+                continue
+            if f > limit:
+                break
+            last = f
+            if pos + f < limit:
+                l.append(("+%d" % f, pos + f))
+            if pos - f >= 0:
+                l.insert(0, ("-%d" % f, pos - f))
+
+        yield {"label": "(0)", "rev": 0}
+
+        for label, rev in l:
+            yield {"label": label, "rev": rev}
+
+        yield {"label": "tip", "rev": "tip"}
+
+    return nav
+
 class hgweb(object):
     def __init__(self, repo, name=None):
         if type(repo) == type(""):
@@ -149,41 +184,6 @@
                                           opts=diffopts), f, tn)
 
     def changelog(self, ctx, shortlog=False):
-        pos = ctx.rev()
-        def changenav(**map):
-            def seq(factor, maxchanges=None):
-                if maxchanges:
-                    yield maxchanges
-                    if maxchanges >= 20 and maxchanges <= 40:
-                        yield 50
-                else:
-                    yield 1 * factor
-                    yield 3 * factor
-                for f in seq(factor * 10):
-                    yield f
-
-            l = []
-            last = 0
-            maxchanges = shortlog and self.maxshortchanges or self.maxchanges
-            for f in seq(1, maxchanges):
-                if f < maxchanges or f <= last:
-                    continue
-                if f > count:
-                    break
-                last = f
-                r = "%d" % f
-                if pos + f < count:
-                    l.append(("+" + r, pos + f))
-                if pos - f >= 0:
-                    l.insert(0, ("-" + r, pos - f))
-
-            yield {"rev": 0, "label": "(0)"}
-
-            for label, rev in l:
-                yield {"label": label, "rev": rev}
-
-            yield {"label": "tip", "rev": "tip"}
-
         def changelist(**map):
             parity = (start - end) & 1
             cl = self.repo.changelog
@@ -210,10 +210,13 @@
         maxchanges = shortlog and self.maxshortchanges or self.maxchanges
         cl = self.repo.changelog
         count = cl.count()
+        pos = ctx.rev()
         start = max(0, pos - maxchanges + 1)
         end = min(count, start + maxchanges)
         pos = end - 1
 
+        changenav = revnavgen(pos, maxchanges, count)
+
         yield self.t(shortlog and 'shortlog' or 'changelog',
                      changenav=changenav,
                      node=hex(cl.tip()),
@@ -306,12 +309,17 @@
         f = fctx.path()
         fl = fctx.filelog()
         count = fl.count()
+        pagelen = self.maxshortchanges
 
         def entries(**map):
+            pos = fctx.filerev()
+            start = max(0, pos - pagelen + 1) 
+            end = min(count, start + pagelen)
+            pos = end - 1
             l = []
             parity = (count - 1) & 1
 
-            for i in range(count):
+            for i in range(start, end):
                 ctx = fctx.filectx(i)
                 n = fl.node(i)
 
@@ -330,7 +338,9 @@
             for e in l:
                 yield e
 
-        yield self.t("filelog", file=f, node=hex(fctx.node()), entries=entries)
+        nav = revnavgen(fctx.filerev(), self.maxshortchanges, count)
+        yield self.t("filelog", file=f, node=hex(fctx.node()), nav=nav,
+                     entries=entries)
 
     def filerevision(self, fctx):
         f = fctx.path()
@@ -553,8 +563,8 @@
     def filediff(self, fctx):
         n = fctx.node()
         path = fctx.path()
-        parents = fctx.changectx().parents()
-        p1 = parents[0].node()
+        parents = fctx.parents()
+        p1 = parents and parents[0].node() or nullid
 
         def diff(**map):
             yield self.diff(p1, n, [path])
--- a/templates/filelog.tmpl	Sun Oct 15 16:18:09 2006 -0500
+++ b/templates/filelog.tmpl	Mon Oct 16 09:23:26 2006 +0200
@@ -17,6 +17,8 @@
 
 <h2>#file|escape# revision history</h2>
 
+<p>navigate: <small class="navigate">{nav%filenaventry}</small></p>
+
 #entries%filelogentry#
 
 #footer#
--- a/templates/gitweb/filelog.tmpl	Sun Oct 15 16:18:09 2006 -0500
+++ b/templates/gitweb/filelog.tmpl	Mon Oct 16 09:23:26 2006 +0200
@@ -19,6 +19,9 @@
 <a href="{url}annotate/{node|short}/#file|urlescape#{sessionvars%urlparameter}">annotate</a> |
 <a href="{url}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}">diff</a> |
 <a href="{url}rss-log/#node|short#/#file|urlescape#">rss</a><br/>
+
+<br/>
+{nav%filenaventry}<br/>
 </div>
 
 <div class="title" >#file|urlescape#</div>
--- a/templates/gitweb/map	Sun Oct 15 16:18:09 2006 -0500
+++ b/templates/gitweb/map	Mon Oct 16 09:23:26 2006 +0200
@@ -7,6 +7,7 @@
 error = error.tmpl
 naventry = '<a href="#url#log/#rev#{sessionvars%urlparameter}">#label|escape#</a> '
 navshortentry = '<a href="#url#shortlog/#rev#{sessionvars%urlparameter}">#label|escape#</a> '
+filenaventry = '<a href="{url}log/{rev}/{file|urlescape}{sessionvars%urlparameter}">{label|escape}</a> '
 filedifflink = '<a href="#url#diff/#node|short#/#file|urlescape#{sessionvars%urlparameter}">#file|escape#</a> '
 filenodelink = '<tr class="parity#parity#"><td><a class="list" href="{url}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}">#file|escape#</a></td><td></td><td class="link"><a href="#url#file/#node|short#/#file|urlescape#{sessionvars%urlparameter}">file</a> | <a href="#url#annotate/#node|short#/#file|urlescape#{sessionvars%urlparameter}">annotate</a> | <a href="#url#diff/#node|short#/#file|urlescape#{sessionvars%urlparameter}">diff</a> | <a href="#url#log/#node|short#/#file|urlescape#{sessionvars%urlparameter}">revisions</a></td></tr>'
 fileellipses = '...'
@@ -41,9 +42,9 @@
 diffblock = '<pre>#lines#</pre>'
 changelogtag = '<tr><th class="tag">tag:</th><td class="tag">#tag|escape#</td></tr>'
 changesettag = '<tr><td>tag</td><td>#tag|escape#</td></tr>'
-filediffparent = '<tr><th class="parent">parent #rev#:</th><td class="parent"><a href="{url}rev/#node|short#{sessionvars%urlparameter}">#node|short#</a></td></tr>'
+filediffparent = '<tr><th class="parent">parent {rev}:</th><td class="parent"><a href="{url}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{node|short}</a></td></tr>'
 filelogparent = '<tr><td align="right">parent #rev#:&nbsp;</td><td><a href="{url}file/{node|short}/#file|urlescape#{sessionvars%urlparameter}">#node|short#</a></td></tr>'
-filediffchild = '<tr><th class="child">child #rev#:</th><td class="child"><a href="{url}rev/#node|short#{sessionvars%urlparameter}">#node|short#</a></td></tr>'
+filediffchild = '<tr><th class="child">child {rev}:</th><td class="child"><a href="{url}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{node|short}</a></td></tr>'
 filelogchild = '<tr><td align="right">child #rev#:&nbsp;</td><td><a href="{url}file{node|short}/#file|urlescape#{sessionvars%urlparameter}">#node|short#</a></td></tr>'
 shortlog = shortlog.tmpl
 shortlogentry = '<tr class="parity#parity#"><td class="age"><i>#date|age# ago</i></td><td><i>#author#</i></td><td><a class="list" href="{url}rev/#node|short#{sessionvars%urlparameter}"><b>#desc|strip|firstline|escape#</b></a></td><td class="link"><a href="{url}rev/#node|short#{sessionvars%urlparameter}">changeset</a> | <a href="{url}file/#node|short#{sessionvars%urlparameter}">manifest</a></td></tr>'
--- a/templates/map	Sun Oct 15 16:18:09 2006 -0500
+++ b/templates/map	Mon Oct 16 09:23:26 2006 +0200
@@ -7,6 +7,7 @@
 shortlogentry = shortlogentry.tmpl
 naventry = '<a href="#url#log/#rev#{sessionvars%urlparameter}">#label|escape#</a> '
 navshortentry = '<a href="#url#shortlog/#rev#{sessionvars%urlparameter}">#label|escape#</a> '
+filenaventry = '<a href="{url}log/{rev}/{file|urlescape}{sessionvars%urlparameter}">{label|escape}</a> '
 filedifflink = '<a href="#url#diff/#node|short#/#file|urlescape#{sessionvars%urlparameter}">#file|escape#</a> '
 filenodelink = '<a href="#url#file/#node|short#/#file|urlescape#{sessionvars%urlparameter}">#file|escape#</a> '
 fileellipses = '...'
--- a/tests/test-annotate	Sun Oct 15 16:18:09 2006 -0500
+++ b/tests/test-annotate	Mon Oct 16 09:23:26 2006 +0200
@@ -71,3 +71,6 @@
 hg ci -mmerge2 -d '4 0'
 echo % annotate after rename merge
 hg annotate -nf b
+
+echo % linkrev vs rev
+hg annotate -r tip a
--- a/tests/test-annotate.out	Sun Oct 15 16:18:09 2006 -0500
+++ b/tests/test-annotate.out	Mon Oct 16 09:23:26 2006 +0200
@@ -48,3 +48,7 @@
 4 b: c
 3 b: b
 7 b: d
+% linkrev vs rev
+0: a
+1: a
+1: a