comparison mercurial/hgweb/webutil.py @ 35485:1721ce06100a

hgweb: display fate of obsolete changesets Operations that obsolete changesets store enough metadata to explain what happened after the fact. One way to get that metadata is showsuccsandmarkers function, which returns a list of successors of a particular changeset and appropriate obsolescence markers. Templates have a set of experimental functions that have names starting with obsfate. This patch uses some of these functions to interpret output of succsandmarkers() and produce human-friendly messages that describe what happened to an obsolete changeset, e.g. "pruned" or "rewritten as 6:3de5eca88c00". In commonentry(), succsandmarkers property is made callable so it's only executed on demand; this saves time when changeset is not obsolete, and also in e.g. /shortlog view, where there are a lot of changesets, but we don't need to show each and every one in detail. In spartan theme, succsandmarkers is used instead of the simple "obsolete: yes", in other themes a new line is added to /rev page.
author Anton Shestakov <av6@dwimlabs.net>
date Tue, 21 Nov 2017 17:03:41 +0800
parents 786289423e97
children 4c7ae95e1c71
comparison
equal deleted inserted replaced
35484:1853c8677160 35485:1721ce06100a
30 mdiff, 30 mdiff,
31 patch, 31 patch,
32 pathutil, 32 pathutil,
33 pycompat, 33 pycompat,
34 templatefilters, 34 templatefilters,
35 templatekw,
35 ui as uimod, 36 ui as uimod,
36 util, 37 util,
37 ) 38 )
38 39
39 def up(p): 40 def up(p):
349 raise ErrorResponse(HTTP_BAD_REQUEST, str(exc)) 350 raise ErrorResponse(HTTP_BAD_REQUEST, str(exc))
350 351
351 def formatlinerange(fromline, toline): 352 def formatlinerange(fromline, toline):
352 return '%d:%d' % (fromline + 1, toline) 353 return '%d:%d' % (fromline + 1, toline)
353 354
355 def succsandmarkers(repo, ctx):
356 return templatekw.showsuccsandmarkers(repo, ctx)
357
354 def commonentry(repo, ctx): 358 def commonentry(repo, ctx):
355 node = ctx.node() 359 node = ctx.node()
356 return { 360 return {
357 'rev': ctx.rev(), 361 'rev': ctx.rev(),
358 'node': hex(node), 362 'node': hex(node),
360 'desc': ctx.description(), 364 'desc': ctx.description(),
361 'date': ctx.date(), 365 'date': ctx.date(),
362 'extra': ctx.extra(), 366 'extra': ctx.extra(),
363 'phase': ctx.phasestr(), 367 'phase': ctx.phasestr(),
364 'obsolete': ctx.obsolete(), 368 'obsolete': ctx.obsolete(),
369 'succsandmarkers': lambda **x: succsandmarkers(repo, ctx),
365 'instabilities': [{"instability": i} for i in ctx.instabilities()], 370 'instabilities': [{"instability": i} for i in ctx.instabilities()],
366 'branch': nodebranchnodefault(ctx), 371 'branch': nodebranchnodefault(ctx),
367 'inbranch': nodeinbranch(repo, ctx), 372 'inbranch': nodeinbranch(repo, ctx),
368 'branches': nodebranchdict(repo, ctx), 373 'branches': nodebranchdict(repo, ctx),
369 'tags': nodetagsdict(repo, node), 374 'tags': nodetagsdict(repo, node),