Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/webcommands.py @ 19486:002b711a3e8a stable
hgweb: fix incorrect way to count revisions in log (issue3977)
Actual amount of revisions is used now instead of their numbers in the repo
before to deal with skipped numbers correctly.
This iterates starting from the newest revision (which is shown on top)
yielding up to the specified count, instead of the reversed order used before.
Effect of this change on efficiency is negligible, when the same changesets are
returned.
author | Alexander Plavin <me@aplavin.ru> |
---|---|
date | Thu, 25 Jul 2013 02:22:39 +0400 |
parents | 02c71f96eb6c |
children | 8cfa3a3664a5 |
comparison
equal
deleted
inserted
replaced
19485:02c71f96eb6c | 19486:002b711a3e8a |
---|---|
198 ctx = web.repo[hi] | 198 ctx = web.repo[hi] |
199 except (error.RepoError, error.LookupError): | 199 except (error.RepoError, error.LookupError): |
200 return _search(web, req, tmpl) # XXX redirect to 404 page? | 200 return _search(web, req, tmpl) # XXX redirect to 404 page? |
201 | 201 |
202 def changelist(latestonly, **map): | 202 def changelist(latestonly, **map): |
203 l = [] # build a list in forward order for efficiency | |
204 revs = [] | 203 revs = [] |
205 if start < end: | 204 if pos != -1: |
206 revs = web.repo.changelog.revs(start, end - 1) | 205 revs = web.repo.changelog.revs(pos, 0) |
207 if latestonly: | 206 if latestonly: |
208 for r in revs: | 207 revs = (next(revs),) |
209 pass | 208 curcount = 0 |
210 revs = (r,) | |
211 for i in revs: | 209 for i in revs: |
212 ctx = web.repo[i] | 210 ctx = web.repo[i] |
213 n = ctx.node() | 211 n = ctx.node() |
214 showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n) | 212 showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n) |
215 files = webutil.listfilediffs(tmpl, ctx.files(), n, web.maxfiles) | 213 files = webutil.listfilediffs(tmpl, ctx.files(), n, web.maxfiles) |
216 | 214 |
217 l.append({"parity": parity.next(), | 215 curcount += 1 |
218 "author": ctx.user(), | 216 if curcount > revcount: |
219 "parent": webutil.parents(ctx, i - 1), | 217 break |
220 "child": webutil.children(ctx, i + 1), | 218 yield {"parity": parity.next(), |
221 "changelogtag": showtags, | 219 "author": ctx.user(), |
222 "desc": ctx.description(), | 220 "parent": webutil.parents(ctx, i - 1), |
223 "extra": ctx.extra(), | 221 "child": webutil.children(ctx, i + 1), |
224 "date": ctx.date(), | 222 "changelogtag": showtags, |
225 "files": files, | 223 "desc": ctx.description(), |
226 "rev": i, | 224 "extra": ctx.extra(), |
227 "node": hex(n), | 225 "date": ctx.date(), |
228 "tags": webutil.nodetagsdict(web.repo, n), | 226 "files": files, |
229 "bookmarks": webutil.nodebookmarksdict(web.repo, n), | 227 "rev": i, |
230 "inbranch": webutil.nodeinbranch(web.repo, ctx), | 228 "node": hex(n), |
231 "branches": webutil.nodebranchdict(web.repo, ctx) | 229 "tags": webutil.nodetagsdict(web.repo, n), |
232 }) | 230 "bookmarks": webutil.nodebookmarksdict(web.repo, n), |
233 for e in reversed(l): | 231 "inbranch": webutil.nodeinbranch(web.repo, ctx), |
234 yield e | 232 "branches": webutil.nodebranchdict(web.repo, ctx) |
233 } | |
235 | 234 |
236 revcount = shortlog and web.maxshortchanges or web.maxchanges | 235 revcount = shortlog and web.maxshortchanges or web.maxchanges |
237 if 'revcount' in req.form: | 236 if 'revcount' in req.form: |
238 revcount = int(req.form.get('revcount', [revcount])[0]) | 237 revcount = int(req.form.get('revcount', [revcount])[0]) |
239 revcount = max(revcount, 1) | 238 revcount = max(revcount, 1) |
244 morevars = copy.copy(tmpl.defaults['sessionvars']) | 243 morevars = copy.copy(tmpl.defaults['sessionvars']) |
245 morevars['revcount'] = revcount * 2 | 244 morevars['revcount'] = revcount * 2 |
246 | 245 |
247 count = len(web.repo) | 246 count = len(web.repo) |
248 pos = ctx.rev() | 247 pos = ctx.rev() |
249 start = max(0, pos - revcount + 1) | 248 parity = paritygen(web.stripecount) |
250 end = pos + 1 | |
251 parity = paritygen(web.stripecount, offset=start - end) | |
252 | 249 |
253 changenav = webutil.revnav(web.repo).gen(pos, revcount, count) | 250 changenav = webutil.revnav(web.repo).gen(pos, revcount, count) |
254 | 251 |
255 return tmpl(shortlog and 'shortlog' or 'changelog', changenav=changenav, | 252 return tmpl(shortlog and 'shortlog' or 'changelog', changenav=changenav, |
256 node=ctx.hex(), rev=pos, changesets=count, | 253 node=ctx.hex(), rev=pos, changesets=count, |