comparison mercurial/hgweb/webutil.py @ 36955:f21798a6bc20

hgweb: explain instabilities of unstable changesets
author Anton Shestakov <av6@dwimlabs.net>
date Mon, 26 Feb 2018 20:44:21 +0800
parents 563fd95a6efb
children c97b936d8bb5
comparison
equal deleted inserted replaced
36954:efc4fb344c05 36955:f21798a6bc20
26 from .. import ( 26 from .. import (
27 context, 27 context,
28 error, 28 error,
29 match, 29 match,
30 mdiff, 30 mdiff,
31 obsutil,
31 patch, 32 patch,
32 pathutil, 33 pathutil,
33 pycompat, 34 pycompat,
34 templatefilters, 35 templatefilters,
35 templatekw, 36 templatekw,
360 yield item 361 yield item
361 362
362 # teach templater succsandmarkers is switched to (context, mapping) API 363 # teach templater succsandmarkers is switched to (context, mapping) API
363 succsandmarkers._requires = {'repo', 'ctx', 'templ'} 364 succsandmarkers._requires = {'repo', 'ctx', 'templ'}
364 365
366 def whyunstable(context, mapping):
367 repo = context.resource(mapping, 'repo')
368 ctx = context.resource(mapping, 'ctx')
369
370 entries = obsutil.whyunstable(repo, ctx)
371 for entry in entries:
372 if entry.get('divergentnodes'):
373 entry['divergentnodes'] = _siblings(entry['divergentnodes'])
374 yield entry
375
376 whyunstable._requires = {'repo', 'ctx', 'templ'}
377
365 def commonentry(repo, ctx): 378 def commonentry(repo, ctx):
366 node = ctx.node() 379 node = ctx.node()
367 return { 380 return {
368 # TODO: perhaps ctx.changectx() should be assigned if ctx is a 381 # TODO: perhaps ctx.changectx() should be assigned if ctx is a
369 # filectx, but I'm not pretty sure if that would always work because 382 # filectx, but I'm not pretty sure if that would always work because
378 'extra': ctx.extra(), 391 'extra': ctx.extra(),
379 'phase': ctx.phasestr(), 392 'phase': ctx.phasestr(),
380 'obsolete': ctx.obsolete(), 393 'obsolete': ctx.obsolete(),
381 'succsandmarkers': succsandmarkers, 394 'succsandmarkers': succsandmarkers,
382 'instabilities': [{"instability": i} for i in ctx.instabilities()], 395 'instabilities': [{"instability": i} for i in ctx.instabilities()],
396 'whyunstable': whyunstable,
383 'branch': nodebranchnodefault(ctx), 397 'branch': nodebranchnodefault(ctx),
384 'inbranch': nodeinbranch(repo, ctx), 398 'inbranch': nodeinbranch(repo, ctx),
385 'branches': nodebranchdict(repo, ctx), 399 'branches': nodebranchdict(repo, ctx),
386 'tags': nodetagsdict(repo, node), 400 'tags': nodetagsdict(repo, node),
387 'bookmarks': nodebookmarksdict(repo, node), 401 'bookmarks': nodebookmarksdict(repo, node),