--- a/hgext3rd/evolve/__init__.py Wed May 10 13:04:31 2017 +0200
+++ b/hgext3rd/evolve/__init__.py Wed May 10 11:52:11 2017 +0200
@@ -3261,15 +3261,18 @@
@eh.command(
'^debugobshistory',
- [('r', 'rev', [], _("revision to debug"))],
- _('hg debugobshistory [OPTION]... [-r] [REV]'))
+ [] + commands.formatteropts,
+ _('hg debugobshistory [OPTION]... [REV]'))
def debugobshistory(ui, repo, *revs, **opts):
revs = scmutil.revrange(repo, revs)
+ fm = ui.formatter('debugobshistory', opts)
for rev in revs:
- _debugobshistorysingle(ui, repo, rev)
-
-def _debugobshistorysingle(ui, repo, rev):
+ _debugobshistorysingle(ui, fm, repo, rev)
+
+ fm.end()
+
+def _debugobshistorysingle(ui, fm, repo, rev):
""" Display the obsolescence history for a single revision
"""
precursors = repo.obsstore.precursors
@@ -3279,41 +3282,66 @@
while nodes:
ctxnode = nodes.pop()
- _debugobshistorydisplaynode(ui, repo, ctxnode)
+ _debugobshistorydisplaynode(ui, fm, repo, ctxnode)
succs = successors.get(ctxnode, ())
+ markerfm = fm.nested("debugobshistory.markers")
for successor in sorted(succs):
- _debugobshistorydisplaymarker(ui, repo, successor)
+ _debugobshistorydisplaymarker(ui, markerfm, repo, successor)
+ markerfm.end()
precs = precursors.get(ctxnode, ())
nodes.extend(precursor[0] for precursor in sorted(precs))
-def _debugobshistorydisplaynode(ui, repo, node):
+def _debugobshistorydisplaynode(ui, fm, repo, node):
ctx = repo.unfiltered()[node]
shortdescription = ctx.description().splitlines()[0]
- args = (ui.label(str(ctx), "evolve.short_node"),
- ui.label(str(int(ctx)), "evolve.rev"),
- ui.label(shortdescription, "evolve.short_description"))
-
- ui.write("%s (%s) %s\n" % args)
-
-def _debugobshistorydisplaymarker(ui, repo, marker):
+ fm.startitem()
+ fm.write('debugobshistory.node', '%s', str(ctx),
+ label="evolve.short_node")
+ fm.plain(' ')
+
+ fm.write('debugobshistory.rev', '(%d)', int(ctx),
+ label="evolve.rev")
+ fm.plain(' ')
+
+ fm.write('debugobshistory.shortdescription', '%s', shortdescription,
+ label="evolve.short_description")
+ fm.plain('\n')
+
+def _debugobshistorydisplaymarker(ui, fm, repo, marker):
succnodes = marker[1]
date = marker[4]
metadata = dict(marker[3])
- msgargs = (ui.label(metadata['user'], "evolve.user"),
- ui.label(util.datestr(date), "evolve.date"))
- # If no successors with a marker, the commit has been pruned
+ fm.startitem()
+ fm.plain(' ')
+
+ # Detect pruned revisions
if len(succnodes) == 0:
- msgargs = (ui.label("pruned", "evolve.verb"),) + msgargs
- msg = " %s by %s (%s)\n"
+ verb = 'pruned'
else:
+ verb = 'rewritten'
+
+ fm.write('debugobshistory.verb', '%s', verb,
+ label="evolve.verb")
+ fm.plain(' by ')
+
+ fm.write('debugobshistory.marker_user', '%s', metadata['user'],
+ label="evolve.user")
+ fm.plain(' ')
+
+ fm.write('debugobshistory.marker_date', '(%s)', fm.formatdate(date),
+ label="evolve.date")
+
+ if len(succnodes) > 0:
+ fm.plain(' as ')
+
shortsnodes = (node.short(succnode) for succnode in sorted(succnodes))
- labelednodes = (ui.label(node, "evolve.short_node") for node in shortsnodes)
- msgargs = (ui.label("rewritten", "evolve.verb"),) + msgargs + (", ".join(labelednodes),)
- msg = " %s by %s (%s) as %s\n"
-
- ui.write(msg % msgargs)
+ nodes = fm.formatlist(shortsnodes, 'debugobshistory.succnodes', sep=', ')
+ fm.write('debugobshistory.succnodes', '%s', nodes,
+ label="evolve.short_node")
+
+ fm.plain("\n")