--- a/hgext3rd/evolve/__init__.py Wed May 17 18:54:48 2017 +0200
+++ b/hgext3rd/evolve/__init__.py Wed May 17 19:20:43 2017 +0200
@@ -148,6 +148,7 @@
obsexchange,
safeguard,
utility,
+ obshistory
)
__version__ = metadata.__version__
@@ -3263,104 +3264,11 @@
'^debugobshistory',
[] + commands.formatteropts,
_('hg debugobshistory [OPTION]... [REV]'))
-def debugobshistory(ui, repo, *revs, **opts):
+def cmdobshistory(ui, repo, *revs, **opts):
revs = scmutil.revrange(repo, revs)
fm = ui.formatter('debugobshistory', opts)
revs.reverse()
- _debugobshistorysingle(fm, repo, revs)
+ obshistory._debugobshistorysingle(fm, repo, revs)
fm.end()
-
-def _debugobshistorysingle(fm, repo, revs):
- """ Display the obsolescence history for a single revision
- """
- precursors = repo.obsstore.precursors
- successors = repo.obsstore.successors
- nodec = repo.changelog.node
- nodes = [nodec(r) for r in revs]
-
- seen = set(nodes)
-
- while nodes:
- ctxnode = nodes.pop()
-
- _debugobshistorydisplaynode(fm, repo, ctxnode)
-
- succs = successors.get(ctxnode, ())
-
- markerfm = fm.nested("debugobshistory.markers")
- for successor in sorted(succs):
- _debugobshistorydisplaymarker(markerfm, repo, successor)
- markerfm.end()
-
- precs = precursors.get(ctxnode, ())
- for p in sorted(precs):
- # Only show nodes once
- if p[0] not in seen:
- seen.add(p[0])
- nodes.append(p[0])
-
-def _debugobshistorydisplaynode(fm, repo, node):
- if node in repo.unfiltered():
- _debugobshistorydisplayctx(fm, repo.unfiltered()[node])
- else:
- _debugobshistorydisplaymissingctx(fm, node)
-
-def _debugobshistorydisplayctx(fm, ctx):
- shortdescription = ctx.description().splitlines()[0]
-
- 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 _debugobshistorydisplaymissingctx(fm, nodewithoutctx):
- hexnode = node.short(nodewithoutctx)
- fm.startitem()
- fm.write('debugobshistory.node', '%s', hexnode,
- label="evolve.short_node evolve.missing_change_ctx")
- fm.plain('\n')
-
-def _debugobshistorydisplaymarker(fm, repo, marker):
- succnodes = marker[1]
- date = marker[4]
- metadata = dict(marker[3])
-
- fm.startitem()
- fm.plain(' ')
-
- # Detect pruned revisions
- if len(succnodes) == 0:
- 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))
- nodes = fm.formatlist(shortsnodes, 'debugobshistory.succnodes', sep=', ')
- fm.write('debugobshistory.succnodes', '%s', nodes,
- label="evolve.short_node")
-
- fm.plain("\n")