--- a/hgext3rd/evolve/obshistory.py Mon Jan 13 16:32:25 2020 +0700
+++ b/hgext3rd/evolve/obshistory.py Thu Jan 16 11:33:53 2020 +0700
@@ -53,6 +53,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'))
@@ -94,7 +95,7 @@
# -f was given, because that doesn't work with templates yet. Note
# that --no-graph doesn't support -f (it ignores it), so we also
# don't use templating with --no-graph.
- if not opts['template'] and not (opts['filternonlocal'] and opts['graph']):
+ if not opts['template'] and not ((opts['filternonlocal'] or opts['origin']) and opts['graph']):
opts['template'] = DEFAULT_TEMPLATE
if opts['graph']:
@@ -164,6 +165,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:
@@ -180,13 +182,24 @@
# Succs markers
if self.filter is False:
- succs = self.repo.obsstore.successors.get(changenode, ())
- succs = sorted(succs)
+ if self.origin:
+ r = predecessorsandmarkers(self.repo, ctx)
+ if r is None:
+ r = []
- for successor in succs:
- _debugobshistorydisplaymarker(self.ui, markerfm, successor,
- ctx.node(), self.repo,
- self._includediff)
+ for predset in sorted(r):
+ markers = predset[b"markers"]
+ if not markers:
+ continue
+ predecessors = predset[b"predecessors"]
+ _debugobshistorydisplaypredsandmarkers(self.ui, markerfm, predecessors, markers, ctx.node(), self.repo, self._includediff)
+ else:
+ markers = self.repo.obsstore.successors.get(changenode, ())
+ for marker in sorted(markers):
+ _debugobshistorydisplaymarker(self.ui, markerfm,
+ marker, ctx.node(),
+ self.repo,
+ self._includediff)
else:
r = obsutil.successorsandmarkers(self.repo, ctx)
@@ -715,6 +728,116 @@
fm.plain(b"\n")
+def _debugobshistorydisplaypredsandmarkers(ui, fm, prednodes, markers, node, repo, includediff=False):
+ """
+ This function is a copy of _debugobshistorydisplaysuccsandmarkers modified
+ to show predecessors and origin of obsolete nodes.
+ """
+ fm.startitem()
+ fm.plain(b' ')
+
+ verb = obsoriginverb(prednodes, markers)
+ fm.write(b'verb', b'%s', verb, label=b"evolve.verb")
+
+ effects = _markerseffects(markers)
+ if effects:
+ fmteffect = fm.formatlist(effects, b'effect', sep=b', ')
+ fm.write(b'effects', b'(%s)', fmteffect)
+
+ if len(prednodes) > 0:
+ fm.plain(b' from ')
+
+ shortsnodes = (nodemod.short(prednode) for prednode in sorted(prednodes))
+ nodes = fm.formatlist(shortsnodes, b'prednode', sep=b', ')
+ fm.write(b'prednodes', b'%s', nodes, label=b"evolve.node")
+
+ # Operations
+ operations = obsutil.markersoperations(markers)
+ if operations:
+ fm.plain(b' using ')
+ fm.write(b'operation', b'%s', b", ".join(operations), label=b"evolve.operation")
+
+ fm.plain(b' by ')
+
+ # Users
+ users = obsutil.markersusers(markers)
+ fm.write(b'user', b'%s', b", ".join(users), label=b"evolve.user")
+ fm.plain(b' ')
+
+ # Dates
+ dates = obsutil.markersdates(markers)
+ if dates:
+ min_date = min(dates)
+ max_date = max(dates)
+
+ if min_date == max_date:
+ fm.write(b"date", b"(at %s)", fm.formatdate(min_date), label=b"evolve.date")
+ else:
+ fm.write(b"date", b"(between %s and %s)", fm.formatdate(min_date),
+ fm.formatdate(max_date), label=b"evolve.date")
+
+ # initial support for showing note
+ # if metadata.get('note'):
+ # fm.plain('\n note: ')
+ # fm.write('note', "%s", metadata['note'], label="evolve.note")
+
+ # Patch display
+ if includediff is True:
+ _patchavailable = patchavailable(node, repo, prednodes, successive=False)
+
+ if _patchavailable[0] is True:
+ pred = _patchavailable[1]
+
+ predctx = repo[pred]
+ basectx = repo[node]
+ # Description patch
+ descriptionpatch = getmarkerdescriptionpatch(repo,
+ predctx.description(),
+ basectx.description())
+
+ if descriptionpatch:
+ # add the diffheader
+ diffheader = b"diff -r %s -r %s changeset-description\n" %\
+ (predctx, basectx)
+ descriptionpatch = diffheader + descriptionpatch
+
+ def tolist(text):
+ return [text]
+
+ ui.pushbuffer(labeled=True)
+ ui.write(b"\n")
+
+ for chunk, label in patch.difflabel(tolist, descriptionpatch):
+ chunk = chunk.strip(b'\t')
+ if chunk and chunk != b'\n':
+ ui.write(b' ')
+ ui.write(chunk, label=label)
+ fm.write(b'descdiff', b'%s', ui.popbuffer())
+
+ # Content patch
+ ui.pushbuffer(labeled=True)
+ diffopts = patch.diffallopts(repo.ui, {})
+ matchfn = scmutil.matchall(repo)
+ firstline = True
+ linestart = True
+ for chunk, label in patch.diffui(repo, pred, node, matchfn,
+ opts=diffopts):
+ if firstline:
+ ui.write(b'\n')
+ firstline = False
+ if linestart:
+ ui.write(b' ')
+ linestart = False
+ if chunk == b'\n':
+ linestart = True
+ ui.write(chunk, label=label)
+ fm.write(b'patch', b'%s', ui.popbuffer())
+ else:
+ fm.write(b'nopatchreason', b"\n (No patch available, %s)",
+ _patchavailable[1])
+
+ fm.plain(b"\n")
+
def _prepare_hunk(hunk):
"""Drop all information but the username and patch"""
cleanunk = []
--- a/tests/test-fold.t Mon Jan 13 16:32:25 2020 +0700
+++ b/tests/test-fold.t Thu Jan 16 11:33:53 2020 +0700
@@ -100,6 +100,33 @@
c8d03c1b5e94af74b772900c58259d2e08917735 198b5c405d01a50c41a81a00fc61677b81981a5f 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '33', 'fold-id': '25cb328e', 'fold-idx': '1', 'fold-size': '3', 'operation': 'fold', 'user': 'test'}
f69452c5b1af6cbaaa56ef50cf94fff5bcc6ca23 198b5c405d01a50c41a81a00fc61677b81981a5f 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '37', 'fold-id': '25cb328e', 'fold-idx': '2', 'fold-size': '3', 'operation': 'fold', 'user': 'test'}
+ $ hg obslog
+ @ 198b5c405d01 (11) r5
+ |\
+ | \
+ | |\
+ x | | 4de32a90b66c (7) r7
+ / / folded(description, date, parent) as 198b5c405d01 using fold by test (Thu Jan 01 00:00:00 1970 +0000)
+ | |
+ x | c8d03c1b5e94 (5) r5
+ / folded(description, date) as 198b5c405d01 using fold by test (Thu Jan 01 00:00:00 1970 +0000)
+ |
+ x f69452c5b1af (6) r6
+ folded(description, date, parent) as 198b5c405d01 using fold by test (Thu Jan 01 00:00:00 1970 +0000)
+
+ $ hg obslog --origin
+ @ 198b5c405d01 (11) r5
+ |\ folded(description, date, parent) from 4de32a90b66c, c8d03c1b5e94, f69452c5b1af using fold by test (at Thu Jan 01 00:00:00 1970 +0000)
+ | |
+ | \
+ | |\
+ x | | 4de32a90b66c (7) r7
+ / /
+ x / c8d03c1b5e94 (5) r5
+ /
+ x f69452c5b1af (6) r6
+
+
Checking whether the bookmarks are moved or not
$ hg log -G