obslog: add flags to control the output of precursors and successors
With just this change, precursors are only shown in structured output.
--- a/hgext3rd/evolve/obshistory.py Sat Feb 01 10:54:20 2020 +0100
+++ b/hgext3rd/evolve/obshistory.py Fri Dec 27 20:38:10 2019 -0800
@@ -52,6 +52,8 @@
(b'r', b'rev', [], _(b'show the specified revision or revset'), _(b'REV')),
(b'a', b'all', False, _(b'show all related changesets, not only precursors')),
(b'p', b'patch', False, _(b'show the patch between two obs versions')),
+ (b'', b'successors', True, _(b'output successors of each revision')),
+ (b'', b'precursors', False, _(b'output precursors of each revision')),
(b'f', b'filternonlocal', False, _(b'filter out non local commits')),
] + commands.formatteropts,
_(b'hg olog [OPTION]... [[-r] REV]...'),
@@ -153,6 +155,8 @@
if not util.safehasattr(self, "_includediff"):
self._includediff = diffopts and diffopts.get(b'patch')
+ self._includesucc = not diffopts or diffopts.get(b'successors', True)
+ self._includeprec = diffopts and diffopts.get(b'precursors')
self.template = diffopts and diffopts.get(b'template')
self.filter = diffopts and diffopts.get(b'filternonlocal')
@@ -167,7 +171,8 @@
_debugobshistorydisplaynode(fm, self.repo, changenode)
_debugobshistorydisplaymarkers(self.ui, self.repo, fm, ctx,
- self.filter, self._includediff)
+ self.filter, self._includesucc,
+ self._includeprec, self._includediff)
fm.plain(b'\n')
fm.end()
@@ -473,17 +478,23 @@
fm.plain(b'\n')
def _debugobshistorydisplaymarkers(ui, repo, fm, ctx, filter_,
+ includesuccessors=True,
+ includeprecursors=False,
includediff=False):
changenode = ctx.node()
markerfm = fm.nested(b"markers")
# Succs markers
if filter_ is False:
- succs = repo.obsstore.successors.get(changenode, ())
- succs = sorted(succs)
+ succs = precs = set()
+ if includesuccessors:
+ succs = repo.obsstore.successors.get(changenode, set())
+ if includeprecursors:
+ precs = repo.obsstore.predecessors.get(changenode, set())
+ markers = sorted(set.union(succs, precs))
- for successor in succs:
- _debugobshistorydisplaymarker(ui, markerfm, successor, changenode,
+ for marker in markers:
+ _debugobshistorydisplaymarker(ui, markerfm, marker, changenode,
repo, includediff)
else:
@@ -502,12 +513,23 @@
def _debugobshistorydisplaymarker(ui, fm, marker, node, repo,
includediff=False):
+ precnode = marker[0]
succnodes = marker[1]
date = marker[4]
metadata = dict(marker[3])
fm.startitem()
+ if precnode == node:
+ # This marker links to a successor of node.
+ nodetype = b'precursor'
+ else:
+ assert node in succnodes
+ # This marker links from a precursor of node.
+ nodetype = b'successor'
+
+ fm.data(nodetype=nodetype)
+
# Detect pruned revisions
if len(succnodes) == 0:
verb = b'pruned'
@@ -525,6 +547,7 @@
hexnodes = (nodemod.hex(succnode) for succnode in sorted(succnodes))
nodes = fm.formatlist(hexnodes, b'succnode')
fm.write(b'succnodes', b'%s', nodes)
+ fm.data(precnode=nodemod.hex(precnode))
operation = metadata.get(b'operation')
if operation:
--- a/tests/test-evolve-cycles.t Sat Feb 01 10:54:20 2020 +0100
+++ b/tests/test-evolve-cycles.t Fri Dec 27 20:38:10 2019 -0800
@@ -305,7 +305,9 @@
"parent",
"content"
],
+ "nodetype": "precursor",
"operation": "prune",
+ "precnode": "868d2e0eb19c2b55a2894d37e1c435c221384d48",
"succnodes": [
"0da815c333f6364b46c86b0a897c00eb617397b6"
],
@@ -328,7 +330,9 @@
"parent",
"content"
],
+ "nodetype": "precursor",
"operation": "prune",
+ "precnode": "d9f908fde1a10ad198a462a3ec8b440bb397fc9c",
"succnodes": [
"868d2e0eb19c2b55a2894d37e1c435c221384d48"
],
@@ -351,7 +355,9 @@
"parent",
"content"
],
+ "nodetype": "precursor",
"operation": "prune",
+ "precnode": "0da815c333f6364b46c86b0a897c00eb617397b6",
"succnodes": [
"d9f908fde1a10ad198a462a3ec8b440bb397fc9c"
],
@@ -374,7 +380,9 @@
"parent",
"content"
],
+ "nodetype": "precursor",
"operation": "prune",
+ "precnode": "a8df460dbbfe9ef0c1e5ab4fff02e9514672e379",
"succnodes": [
"2a34000d35446022104f7a091c06fe21ff2b5912",
"868d2e0eb19c2b55a2894d37e1c435c221384d48"
@@ -398,7 +406,9 @@
"parent",
"content"
],
+ "nodetype": "precursor",
"operation": "prune",
+ "precnode": "c473644ee0e988d7f537e31423831bbc409f12f7",
"succnodes": [
"a8df460dbbfe9ef0c1e5ab4fff02e9514672e379"
],
@@ -421,7 +431,9 @@
"parent",
"content"
],
+ "nodetype": "precursor",
"operation": "prune",
+ "precnode": "2a34000d35446022104f7a091c06fe21ff2b5912",
"succnodes": [
"c473644ee0e988d7f537e31423831bbc409f12f7"
],
--- a/tests/test-evolve-obshistory-amend-then-fold.t Sat Feb 01 10:54:20 2020 +0100
+++ b/tests/test-evolve-obshistory-amend-then-fold.t Fri Dec 27 20:38:10 2019 -0800
@@ -167,7 +167,9 @@
*, (glob)
"content"
],
+ "nodetype": "precursor",
"operation": "fold",
+ "precnode": "b7ea6d14e664bdc8922221f7992631b50da3fb07",
"succnodes": [
"eb5a0daa21923bbf8caeb2c42085b9e463861fd0"
],
@@ -188,7 +190,9 @@
"effects": [
"description"
],
+ "nodetype": "precursor",
"operation": "amend",
+ "precnode": "0dec01379d3be6318c470ead31b1fe7ae7cb53d5",
"succnodes": [
"b7ea6d14e664bdc8922221f7992631b50da3fb07"
],
@@ -210,7 +214,9 @@
"description",
"content"
],
+ "nodetype": "precursor",
"operation": "fold",
+ "precnode": "471f378eab4c5e25f6c77f785b27c936efb22874",
"succnodes": [
"eb5a0daa21923bbf8caeb2c42085b9e463861fd0"
],
--- a/tests/test-evolve-obshistory-amend.t Sat Feb 01 10:54:20 2020 +0100
+++ b/tests/test-evolve-obshistory-amend.t Fri Dec 27 20:38:10 2019 -0800
@@ -159,7 +159,9 @@
"description",
"content"
],
+ "nodetype": "precursor",
"operation": "amend",
+ "precnode": "471f378eab4c5e25f6c77f785b27c936efb22874",
"succnodes": [
"4ae3a4151de9aa872113f0b196e28323308981e8"
],
@@ -204,7 +206,9 @@
*, (glob)
"content"
],
+ "nodetype": "precursor",
"operation": "amend",
+ "precnode": "471f378eab4c5e25f6c77f785b27c936efb22874",
"succnodes": [
"4ae3a4151de9aa872113f0b196e28323308981e8"
],
--- a/tests/test-evolve-obshistory-content-divergent.t Sat Feb 01 10:54:20 2020 +0100
+++ b/tests/test-evolve-obshistory-content-divergent.t Fri Dec 27 20:38:10 2019 -0800
@@ -136,7 +136,9 @@
"effects": [
"description"
],
+ "nodetype": "precursor",
"operation": "amend",
+ "precnode": "471f378eab4c5e25f6c77f785b27c936efb22874",
"succnodes": [
"65b757b745b935093c87a2bccd877521cccffcbd"
],
@@ -151,7 +153,9 @@
"effects": [
"description"
],
+ "nodetype": "precursor",
"operation": "amend",
+ "precnode": "471f378eab4c5e25f6c77f785b27c936efb22874",
"succnodes": [
"fdf9bde5129a28d4548fadd3f62b265cdd3b7a2e"
],
@@ -300,7 +304,9 @@
"effects": [
"description"
],
+ "nodetype": "precursor",
"operation": "amend",
+ "precnode": "471f378eab4c5e25f6c77f785b27c936efb22874",
"succnodes": [
"65b757b745b935093c87a2bccd877521cccffcbd"
],
@@ -315,7 +321,9 @@
"effects": [
"description"
],
+ "nodetype": "precursor",
"operation": "amend",
+ "precnode": "471f378eab4c5e25f6c77f785b27c936efb22874",
"succnodes": [
"fdf9bde5129a28d4548fadd3f62b265cdd3b7a2e"
],
--- a/tests/test-evolve-obshistory-fold.t Sat Feb 01 10:54:20 2020 +0100
+++ b/tests/test-evolve-obshistory-fold.t Fri Dec 27 20:38:10 2019 -0800
@@ -186,7 +186,9 @@
"description",
"content"
],
+ "nodetype": "precursor",
"operation": "fold",
+ "precnode": "471f378eab4c5e25f6c77f785b27c936efb22874",
"succnodes": [
"eb5a0daa21923bbf8caeb2c42085b9e463861fd0"
],
@@ -209,7 +211,9 @@
"parent",
"content"
],
+ "nodetype": "precursor",
"operation": "fold",
+ "precnode": "0dec01379d3be6318c470ead31b1fe7ae7cb53d5",
"succnodes": [
"eb5a0daa21923bbf8caeb2c42085b9e463861fd0"
],
--- a/tests/test-evolve-obshistory-lots-of-splits.t Sat Feb 01 10:54:20 2020 +0100
+++ b/tests/test-evolve-obshistory-lots-of-splits.t Fri Dec 27 20:38:10 2019 -0800
@@ -205,7 +205,9 @@
"parent",
"content"
],
+ "nodetype": "precursor",
"operation": "split",
+ "precnode": "de7290d8b885925115bb9e88887252dfc20ef2a8",
"succnodes": [
"1ae8bc733a14e374f11767d2ad128d4c891dc43f",
"337fec4d2edcf0e7a467e35f818234bc620068b5",
@@ -245,7 +247,9 @@
"parent",
"content"
],
+ "nodetype": "precursor",
"operation": "split",
+ "precnode": "de7290d8b885925115bb9e88887252dfc20ef2a8",
"succnodes": [
"1ae8bc733a14e374f11767d2ad128d4c891dc43f",
"337fec4d2edcf0e7a467e35f818234bc620068b5",
--- a/tests/test-evolve-obshistory-phase-divergent.t Sat Feb 01 10:54:20 2020 +0100
+++ b/tests/test-evolve-obshistory-phase-divergent.t Fri Dec 27 20:38:10 2019 -0800
@@ -105,7 +105,9 @@
"effects": [
"description"
],
+ "nodetype": "precursor",
"operation": "amend",
+ "precnode": "471f378eab4c5e25f6c77f785b27c936efb22874",
"succnodes": [
"fdf9bde5129a28d4548fadd3f62b265cdd3b7a2e"
],
@@ -208,7 +210,9 @@
"effects": [
"description"
],
+ "nodetype": "precursor",
"operation": "amend",
+ "precnode": "471f378eab4c5e25f6c77f785b27c936efb22874",
"succnodes": [
"fdf9bde5129a28d4548fadd3f62b265cdd3b7a2e"
],
--- a/tests/test-evolve-obshistory-prune.t Sat Feb 01 10:54:20 2020 +0100
+++ b/tests/test-evolve-obshistory-prune.t Fri Dec 27 20:38:10 2019 -0800
@@ -77,7 +77,9 @@
*, (glob)
0 (glob)
],
+ "nodetype": "precursor",
"operation": "prune",
+ "precnode": "0dec01379d3be6318c470ead31b1fe7ae7cb53d5",
"user": "test",
"verb": "pruned"
}
--- a/tests/test-evolve-obshistory-split.t Sat Feb 01 10:54:20 2020 +0100
+++ b/tests/test-evolve-obshistory-split.t Fri Dec 27 20:38:10 2019 -0800
@@ -123,8 +123,10 @@
"parent",
"content"
],
+ "nodetype": "precursor",
"note": "testing split",
"operation": "split",
+ "precnode": "471597cad322d1f659bb169751be9133dad92ef3",
"succnodes": [
"337fec4d2edcf0e7a467e35f818234bc620068b5",
"f257fde29c7a847c9b607f6e958656d0df0fb15c"