diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py --- a/mercurial/templatekw.py +++ b/mercurial/templatekw.py @@ -802,7 +802,7 @@ def showwhyunstable(context, mapping): ctx = context.resource(mapping, 'ctx') def formatnode(ctx): - return ' %s (%s)' % (scmutil.formatchangeid(ctx), ctx.phasestr()) + return '%s (%s)' % (scmutil.formatchangeid(ctx), ctx.phasestr()) entries = obsutil.whyunstable(repo, ctx) @@ -814,7 +814,8 @@ def showwhyunstable(context, mapping): lambda x: formatnode(repo[x])) entry['divergentnodes'] = dnhybrid - tmpl = '{instability}:{divergentnodes} {reason} {node|short}' + tmpl = ('{instability}:{if(divergentnodes, " ")}{divergentnodes} ' + '{reason} {node|short}') return templateutil.mappinglist(entries, tmpl=tmpl, sep='\n') def loadkeyword(ui, extname, registrarobj): diff --git a/tests/test-obsolete-divergent.t b/tests/test-obsolete-divergent.t --- a/tests/test-obsolete-divergent.t +++ b/tests/test-obsolete-divergent.t @@ -17,7 +17,7 @@ Enable obsolete > [phases] > publish=False > [templates] - > wuentryshort = '{instability}:{divergentnodes} {reason} {node|shortest}\n' + > wuentryshort = '{instability}:{if(divergentnodes, " ")}{divergentnodes} {reason} {node|shortest}\n' > whyunstableshort = '{whyunstable % wuentryshort}' > wuentryshorter = '{instability}:{divergentnodes % " {node|shortest} ({phase})"} {reason} {node|shortest}\n' > whyunstableshorter = '{whyunstable % wuentryshorter}' @@ -531,6 +531,16 @@ Check more complex obsolescence graft (w 9:14608b260df8 A_8 10:bed64f5d2f5a A_9 + $ hg log -r bed64f5d2f5a -T '{whyunstable}\n' | sort + content-divergent: 4:01f36c5a8fda (draft) 8:7ae126973a96 (draft) 9:14608b260df8 (draft) predecessor 007dc284c1f8 + content-divergent: 8:7ae126973a96 (draft) 9:14608b260df8 (draft) predecessor e442cfc57690 + $ hg log -r bed64f5d2f5a -T whyunstableshort | sort + content-divergent: 4:01f36c5a8fda (draft) 8:7ae126973a96 (draft) 9:14608b260df8 (draft) predecessor 007d + content-divergent: 8:7ae126973a96 (draft) 9:14608b260df8 (draft) predecessor e442 + $ hg log -r bed64f5d2f5a -T whyunstableshorter | sort + content-divergent: 01f3 (draft) 7ae1 (draft) 1460 (draft) predecessor 007d + content-divergent: 7ae1 (draft) 1460 (draft) predecessor e442 + fix the divergence $ mkcommit A_A; hg up 0