Mercurial > evolve
changeset 5299:2d48fc2c47fc
obslog: add preliminary support for showing predecessors
This functionality is not yet used right now, but will be in the next patch.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Tue, 21 Apr 2020 23:45:11 +0800 |
parents | b117e4732656 |
children | a9f9edb168a1 |
files | hgext3rd/evolve/obshistory.py |
diffstat | 1 files changed, 31 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/obshistory.py Fri Apr 24 01:15:38 2020 +0800 +++ b/hgext3rd/evolve/obshistory.py Tue Apr 21 23:45:11 2020 +0800 @@ -112,8 +112,10 @@ b"presentnode": TEMPLATE_PRESENT_NODE, b"missingnode": TEMPLATE_MISSING_NODE } +TEMPLATE_PREDNODES = b"""{label("evolve.node", join(prednodes % "{prednode|short}", ", "))}""" TEMPLATE_SUCCNODES = b"""{label("evolve.node", join(succnodes % "{succnode|short}", ", "))}""" -TEMPLATE_NODES = b"""{if(succnodes, "as %(succnodes)s")}""" % { +TEMPLATE_NODES = b"""{if(prednodes, "from %(prednodes)s")}{if(succnodes, "as %(succnodes)s")}""" % { + b"prednodes": TEMPLATE_PREDNODES, b"succnodes": TEMPLATE_SUCCNODES } TEMPLATE_REWRITE = b"""{label("evolve.verb", verb)}{if(effects, "({join(effects, ", ")})")}""" @@ -606,10 +608,14 @@ label=b"evolve.node evolve.missing_change_ctx") fm.plain(b'\n') -def displaymarkers(ui, fm, succnodes, markers, node, repo, includediff=False): +def displaymarkers(ui, fm, nodes, markers, node, repo, includediff=False, + successive=True): fm.startitem() - verb = _successorsetverb(succnodes, markers)[b"verb"] + if successive: + verb = _successorsetverb(nodes, markers)[b"verb"] + else: + verb = _predecessorsverb(nodes, markers) fm.data(verb=verb) @@ -618,10 +624,14 @@ fmteffects = fm.formatlist(effects, b'effect', sep=b', ') fm.data(effects=fmteffects) - if len(succnodes) > 0: - hexnodes = (nodemod.hex(succnode) for succnode in sorted(succnodes)) - nodes = fm.formatlist(hexnodes, b'succnode') - fm.data(succnodes=nodes) + if len(nodes) > 0: + hexnodes = (nodemod.hex(node) for node in sorted(nodes)) + if successive: + nodelist = fm.formatlist(hexnodes, b'succnode') + fm.data(succnodes=nodelist) + else: + nodelist = fm.formatlist(hexnodes, b'prednode') + fm.data(prednodes=nodelist) # Operations operations = obsutil.markersoperations(markers) @@ -643,22 +653,27 @@ # Patch display if includediff is True: - _patchavailable = patchavailable(node, repo, succnodes) + _patchavailable = patchavailable(node, repo, nodes, + successive=successive) if _patchavailable[0] is True: - succ = _patchavailable[1] + diffnode = _patchavailable[1] - basectx = repo[node] - succctx = repo[succ] + if successive: + actx = repo[node] + bctx = repo[diffnode] + else: + actx = repo[diffnode] + bctx = repo[node] # Description patch descriptionpatch = getmarkerdescriptionpatch(repo, - basectx.description(), - succctx.description()) + actx.description(), + bctx.description()) if descriptionpatch: # add the diffheader diffheader = b"diff -r %s -r %s changeset-description\n" %\ - (basectx, succctx) + (actx, bctx) descriptionpatch = diffheader + descriptionpatch def tolist(text): @@ -678,8 +693,8 @@ matchfn = scmutil.matchall(repo) firstline = True linestart = True - for chunk, label in patch.diffui(repo, node, succ, matchfn, - opts=diffopts): + for chunk, label in patch.diffui(repo, actx.node(), bctx.node(), + matchfn, opts=diffopts): if firstline: ui.write(b'\n') firstline = False