Mercurial > evolve
changeset 5300:a9f9edb168a1
obslog: add a --origin flag to show predecessors instead of successors
This flag will be turned on by default in the next changeset.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Thu, 07 May 2020 01:29:24 +0200 |
parents | 2d48fc2c47fc |
children | e8660b28bfee |
files | hgext3rd/evolve/obshistory.py |
diffstat | 1 files changed, 32 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/obshistory.py Tue Apr 21 23:45:11 2020 +0800 +++ b/hgext3rd/evolve/obshistory.py Thu May 07 01:29:24 2020 +0200 @@ -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,18 +213,31 @@ 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: - 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,10 +277,11 @@ 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(), - 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,10 +583,10 @@ 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, - includediff) + includediff, successive=not origin) markerfm.end()