diff 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
line wrap: on
line diff
--- a/mercurial/hgweb/webutil.py	Mon Feb 26 20:44:01 2018 +0800
+++ b/mercurial/hgweb/webutil.py	Mon Feb 26 20:44:21 2018 +0800
@@ -28,6 +28,7 @@
     error,
     match,
     mdiff,
+    obsutil,
     patch,
     pathutil,
     pycompat,
@@ -362,6 +363,18 @@
 # teach templater succsandmarkers is switched to (context, mapping) API
 succsandmarkers._requires = {'repo', 'ctx', 'templ'}
 
+def whyunstable(context, mapping):
+    repo = context.resource(mapping, 'repo')
+    ctx = context.resource(mapping, 'ctx')
+
+    entries = obsutil.whyunstable(repo, ctx)
+    for entry in entries:
+        if entry.get('divergentnodes'):
+            entry['divergentnodes'] = _siblings(entry['divergentnodes'])
+        yield entry
+
+whyunstable._requires = {'repo', 'ctx', 'templ'}
+
 def commonentry(repo, ctx):
     node = ctx.node()
     return {
@@ -380,6 +393,7 @@
         'obsolete': ctx.obsolete(),
         'succsandmarkers': succsandmarkers,
         'instabilities': [{"instability": i} for i in ctx.instabilities()],
+        'whyunstable': whyunstable,
         'branch': nodebranchnodefault(ctx),
         'inbranch': nodeinbranch(repo, ctx),
         'branches': nodebranchdict(repo, ctx),