Commit 2d48fc2c authored by Anton Shestakov's avatar Anton Shestakov
Browse files

obslog: add preliminary support for showing predecessors

This functionality is not yet used right now, but will be in the next patch.
parent b117e4732656
......@@ -112,4 +112,5 @@
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}", ", "))}"""
......@@ -115,5 +116,6 @@
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,6 +608,7 @@
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()
......@@ -610,6 +613,9 @@
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,6 +653,7 @@
# Patch display
if includediff is True:
_patchavailable = patchavailable(node, repo, succnodes)
_patchavailable = patchavailable(node, repo, nodes,
successive=successive)
if _patchavailable[0] is True:
......@@ -647,4 +658,4 @@
if _patchavailable[0] is True:
succ = _patchavailable[1]
diffnode = _patchavailable[1]
......@@ -650,5 +661,9 @@
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,
......@@ -653,8 +668,8 @@
# 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" %\
......@@ -657,8 +672,8 @@
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
......
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