--- a/mercurial/context.py Tue Oct 17 18:48:41 2006 -0500
+++ b/mercurial/context.py Tue Oct 17 18:54:37 2006 -0500
@@ -256,10 +256,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 Tue Oct 17 18:48:41 2006 -0500
+++ b/mercurial/hgweb/hgweb_mod.py Tue Oct 17 18:54:37 2006 -0500
@@ -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
+ pos = fctx.filerev()
+ start = max(0, pos - pagelen + 1)
+ end = min(count, start + pagelen)
+ pos = end - 1
def entries(**map):
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(pos, pagelen, 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 Tue Oct 17 18:48:41 2006 -0500
+++ b/templates/filelog.tmpl Tue Oct 17 18:54:37 2006 -0500
@@ -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 Tue Oct 17 18:48:41 2006 -0500
+++ b/templates/gitweb/filelog.tmpl Tue Oct 17 18:54:37 2006 -0500
@@ -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 Tue Oct 17 18:48:41 2006 -0500
+++ b/templates/gitweb/map Tue Oct 17 18:54:37 2006 -0500
@@ -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#: </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#: </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 Tue Oct 17 18:48:41 2006 -0500
+++ b/templates/map Tue Oct 17 18:54:37 2006 -0500
@@ -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 = '...'
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/old/footer.tmpl Tue Oct 17 18:54:37 2006 -0500
@@ -0,0 +1,8 @@
+#motd#
+<div class="logo">
+powered by<br/>
+<a href="http://www.selenic.com/mercurial/">mercurial</a>
+</div>
+
+</body>
+</html>
--- a/templates/rss/filelogentry.tmpl Tue Oct 17 18:48:41 2006 -0500
+++ b/templates/rss/filelogentry.tmpl Tue Oct 17 18:54:37 2006 -0500
@@ -3,5 +3,5 @@
<link>#url#?f=#node|short#;file=#file|urlescape#</link>
<description><![CDATA[#desc|strip|escape|addbreaks#]]></description>
<author>#author|obfuscate#</author>
- <pubDate>#date|rfc822date#</pubDate>>
+ <pubDate>#date|rfc822date#</pubDate>
</item>
--- a/tests/test-annotate Tue Oct 17 18:48:41 2006 -0500
+++ b/tests/test-annotate Tue Oct 17 18:54:37 2006 -0500
@@ -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 Tue Oct 17 18:48:41 2006 -0500
+++ b/tests/test-annotate.out Tue Oct 17 18:54:37 2006 -0500
@@ -48,3 +48,7 @@
4 b: c
3 b: b
7 b: d
+% linkrev vs rev
+0: a
+1: a
+1: a