obshistory: only display each revision once in debugobshistory
When using a revision range, the same precursor could have been
displayed more than once. Use a cache to display each revision
only once.
It's a fix until we found the nicest way to display obs history.
--- a/hgext3rd/evolve/__init__.py Fri May 12 11:39:41 2017 +0200
+++ b/hgext3rd/evolve/__init__.py Fri May 12 18:34:37 2017 +0200
@@ -3267,22 +3267,25 @@
revs = scmutil.revrange(repo, revs)
fm = ui.formatter('debugobshistory', opts)
- for rev in revs:
- _debugobshistorysingle(ui, fm, repo, rev)
+ revs.reverse()
+ _debugobshistorysingle(fm, repo, revs)
fm.end()
-def _debugobshistorysingle(ui, fm, repo, rev):
+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(rev)]
+ nodes = [nodec(r) for r in revs]
+
+ seen = set(nodes)
while nodes:
ctxnode = nodes.pop()
- _debugobshistorydisplaynode(ui, fm, repo, ctxnode)
+
+ _debugobshistorydisplaynode(fm, repo, ctxnode)
succs = successors.get(ctxnode, ())
@@ -3292,9 +3295,13 @@
markerfm.end()
precs = precursors.get(ctxnode, ())
- nodes.extend(precursor[0] for precursor in sorted(precs))
-
-def _debugobshistorydisplaynode(ui, fm, repo, node):
+ 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:
--- a/tests/test-evolve-obshistory.t Fri May 12 11:39:41 2017 +0200
+++ b/tests/test-evolve-obshistory.t Fri May 12 18:34:37 2017 +0200
@@ -612,6 +612,13 @@
"debugobshistory.shortdescription": "A0"
}
]
+ $ hg debugobshistory 2:5
+ 337fec4d2edc (2) A0
+ de7290d8b885 (1) A0
+ rewritten by test (*20*) as 1ae8bc733a14, 337fec4d2edc, c7f044602e9b, f257fde29c7a (glob)
+ f257fde29c7a (3) A0
+ 1ae8bc733a14 (4) A0
+ c7f044602e9b (5) A0
$ hg update de7290d8b885
abort: hidden revision 'de7290d8b885'!
(use --hidden to access hidden revisions; successors: 337fec4d2edc, f257fde29c7a and 2 more)