Commit a9f9edb1 authored by Anton Shestakov's avatar Anton Shestakov
Browse files

obslog: add a --origin flag to show predecessors instead of successors

This flag will be turned on by default in the next changeset.
parent 2d48fc2c47fc
Pipeline #5817 canceled with stage
in 45 seconds
......@@ -59,6 +59,7 @@
(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'f', b'filternonlocal', False, _(b'filter out non local commits')),
(b'o', b'origin', False, _(b'show origin of changesets instead of fate')),
] + commands.formatteropts,
_(b'hg olog [OPTION]... [[-r] REV]...'),
**compat.helpcategorykwargs('CATEGORY_CHANGE_NAVIGATION'))
......@@ -212,12 +213,17 @@
if not marker[1]:
yield ((), (marker,))
def _nodesandmarkers(repo, ctx, filternonlocal):
if filternonlocal:
r = obsutil.successorsandmarkers(repo, ctx)
if r is None:
r = []
for succset in sorted(r):
if succset[b'markers']:
yield (succset[b'successors'], succset[b'markers'])
def _nodesandmarkers(repo, ctx, filternonlocal, origin):
""" Return data for obslog and obsolescence-related template keywords.
If `filternonlocal` is True, skip filtered nodes (but still gather
obsolescence markers), otherwise the result will contain nodes unknown
locally if they are found in the obsolescence markers.
If `origin` is True, look at predecessors of ctx. Otherwise return
successors and appropriate obsmarkers.
"""
if origin:
for (nodes, markers) in _originmarkers(repo, ctx, filternonlocal):
yield (nodes, markers)
else:
......@@ -223,7 +229,15 @@
else:
markers = repo.obsstore.successors.get(ctx.node(), ())
for marker in sorted(markers):
yield (marker[1], [marker])
if filternonlocal:
r = obsutil.successorsandmarkers(repo, ctx)
if r is None:
r = []
for succset in sorted(r):
if succset[b'markers']:
yield (succset[b'successors'], succset[b'markers'])
else:
markers = repo.obsstore.successors.get(ctx.node(), ())
for marker in sorted(markers):
yield (marker[1], [marker])
class obsmarker_printer(logcmdutil.changesetprinter):
"""show (available) information about a node
......@@ -248,6 +262,7 @@
self.template = diffopts and diffopts.get(b'template')
self.filter = diffopts and diffopts.get(b'filternonlocal')
self.origin = diffopts and diffopts.get(b'origin')
def show(self, ctx, copies=None, matchfn=None, **props):
if self.buffered:
......@@ -262,6 +277,6 @@
markerfm = fm.nested(b"markers")
data = _nodesandmarkers(self.repo, ctx, self.filter)
data = _nodesandmarkers(self.repo, ctx, self.filter, self.origin)
for nodes, markers in data:
displaymarkers(self.ui, markerfm, nodes, markers, ctx.node(),
......@@ -266,6 +281,7 @@
for nodes, markers in data:
displaymarkers(self.ui, markerfm, nodes, markers, ctx.node(),
self.repo, self._includediff)
self.repo, self._includediff,
successive=not self.origin)
markerfm.end()
......@@ -534,6 +550,7 @@
seen = set(nodes)
toshow = []
origin = opts and opts.get('origin')
walksuccessors = opts and opts.get('all')
filternonlocal = opts and opts.get('filternonlocal')
includediff = opts and opts.get('patch')
......@@ -566,6 +583,6 @@
markerfm = fm.nested(b"markers")
data = _nodesandmarkers(unfi, ctx, filternonlocal)
data = _nodesandmarkers(unfi, ctx, filternonlocal, origin)
for nodes_, markers in data:
displaymarkers(ui, markerfm, nodes_, markers, ctx.node(), unfi,
......@@ -570,6 +587,6 @@
for nodes_, markers in data:
displaymarkers(ui, markerfm, nodes_, markers, ctx.node(), unfi,
includediff)
includediff, successive=not origin)
markerfm.end()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment