Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/hgweb_mod.py @ 3422:0eba7e76cd02
Convert changenav bar from revisions to hashes (closes issue189)
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Mon, 16 Oct 2006 11:02:11 -0700 |
parents | 1ae738bacf74 |
children | a2179e78d18b |
comparison
equal
deleted
inserted
replaced
3411:5207cf649abe | 3422:0eba7e76cd02 |
---|---|
26 up = os.path.dirname(p) | 26 up = os.path.dirname(p) |
27 if up == "/": | 27 if up == "/": |
28 return "/" | 28 return "/" |
29 return up + "/" | 29 return up + "/" |
30 | 30 |
31 def revnavgen(pos, pagelen, limit): | 31 def revnavgen(pos, pagelen, limit, nodefunc): |
32 def seq(factor, limit=None): | 32 def seq(factor, limit=None): |
33 if limit: | 33 if limit: |
34 yield limit | 34 yield limit |
35 if limit >= 20 and limit <= 40: | 35 if limit >= 20 and limit <= 40: |
36 yield 50 | 36 yield 50 |
48 continue | 48 continue |
49 if f > limit: | 49 if f > limit: |
50 break | 50 break |
51 last = f | 51 last = f |
52 if pos + f < limit: | 52 if pos + f < limit: |
53 l.append(("+%d" % f, pos + f)) | 53 l.append(("+%d" % f, hex(nodefunc(pos + f).node()))) |
54 if pos - f >= 0: | 54 if pos - f >= 0: |
55 l.insert(0, ("-%d" % f, pos - f)) | 55 l.insert(0, ("-%d" % f, hex(nodefunc(pos - f).node()))) |
56 | 56 |
57 yield {"label": "(0)", "rev": 0} | 57 yield {"label": "(0)", "node": hex(nodefunc(0).node())} |
58 | 58 |
59 for label, rev in l: | 59 for label, node in l: |
60 yield {"label": label, "rev": rev} | 60 yield {"label": label, "node": node} |
61 | 61 |
62 yield {"label": "tip", "rev": "tip"} | 62 yield {"label": "tip", "node": hex(nodefunc('-1').node())} |
63 | 63 |
64 return nav | 64 return nav |
65 | 65 |
66 class hgweb(object): | 66 class hgweb(object): |
67 def __init__(self, repo, name=None): | 67 def __init__(self, repo, name=None): |
213 pos = ctx.rev() | 213 pos = ctx.rev() |
214 start = max(0, pos - maxchanges + 1) | 214 start = max(0, pos - maxchanges + 1) |
215 end = min(count, start + maxchanges) | 215 end = min(count, start + maxchanges) |
216 pos = end - 1 | 216 pos = end - 1 |
217 | 217 |
218 changenav = revnavgen(pos, maxchanges, count) | 218 changenav = revnavgen(pos, maxchanges, count, self.repo.changectx) |
219 | 219 |
220 yield self.t(shortlog and 'shortlog' or 'changelog', | 220 yield self.t(shortlog and 'shortlog' or 'changelog', |
221 changenav=changenav, | 221 changenav=changenav, |
222 node=hex(cl.tip()), | 222 node=hex(cl.tip()), |
223 rev=pos, changesets=count, entries=changelist, | 223 rev=pos, changesets=count, entries=changelist, |
336 parity = 1 - parity | 336 parity = 1 - parity |
337 | 337 |
338 for e in l: | 338 for e in l: |
339 yield e | 339 yield e |
340 | 340 |
341 nav = revnavgen(pos, pagelen, count) | 341 nodefunc = lambda x: fctx.filectx(fileid=x) |
342 nav = revnavgen(pos, pagelen, count, nodefunc) | |
342 yield self.t("filelog", file=f, node=hex(fctx.node()), nav=nav, | 343 yield self.t("filelog", file=f, node=hex(fctx.node()), nav=nav, |
343 entries=entries) | 344 entries=entries) |
344 | 345 |
345 def filerevision(self, fctx): | 346 def filerevision(self, fctx): |
346 f = fctx.path() | 347 f = fctx.path() |