# HG changeset patch # User Thomas Arendsen Hein # Date 1160983406 -7200 # Node ID 4e0c08f019b8ee5ccb9a2359e64a550e121f16da # Parent 03e7e8958a27017c1a1080c0de8eaf9b862f3ec4# Parent d2b55e3c4e25e45e85ec7df9120937866a9f33d3 merge with main diff -r d2b55e3c4e25 -r 4e0c08f019b8 mercurial/commands.py diff -r d2b55e3c4e25 -r 4e0c08f019b8 mercurial/context.py --- 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): diff -r d2b55e3c4e25 -r 4e0c08f019b8 mercurial/hgweb/hgweb_mod.py --- 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]) diff -r d2b55e3c4e25 -r 4e0c08f019b8 templates/filelog.tmpl --- 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 @@

#file|escape# revision history

+

navigate: {nav%filenaventry}

+ #entries%filelogentry# #footer# diff -r d2b55e3c4e25 -r 4e0c08f019b8 templates/gitweb/filelog.tmpl --- 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 @@ annotate | diff | rss
+ +
+{nav%filenaventry}
#file|urlescape#
diff -r d2b55e3c4e25 -r 4e0c08f019b8 templates/gitweb/map --- 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 = '#label|escape# ' navshortentry = '#label|escape# ' +filenaventry = '{label|escape} ' filedifflink = '#file|escape# ' filenodelink = '#file|escape#file | annotate | diff | revisions' fileellipses = '...' @@ -41,9 +42,9 @@ diffblock = '
#lines#
' changelogtag = 'tag:#tag|escape#' changesettag = 'tag#tag|escape#' -filediffparent = 'parent #rev#:#node|short#' +filediffparent = 'parent {rev}:{node|short}' filelogparent = 'parent #rev#: #node|short#' -filediffchild = 'child #rev#:#node|short#' +filediffchild = 'child {rev}:{node|short}' filelogchild = 'child #rev#: #node|short#' shortlog = shortlog.tmpl shortlogentry = '#date|age# ago#author##desc|strip|firstline|escape#changeset | manifest' diff -r d2b55e3c4e25 -r 4e0c08f019b8 templates/map --- 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 = '#label|escape# ' navshortentry = '#label|escape# ' +filenaventry = '{label|escape} ' filedifflink = '#file|escape# ' filenodelink = '#file|escape# ' fileellipses = '...' diff -r d2b55e3c4e25 -r 4e0c08f019b8 tests/test-annotate --- 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 diff -r d2b55e3c4e25 -r 4e0c08f019b8 tests/test-annotate.out --- 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