smartlog: only count visible successors

Invisible successors could be confusing. Therefore only show visible
successors.

Differential Revision: https://phab.mercurial-scm.org/D149
This commit is contained in:
Jun Wu 2017-07-19 10:43:01 -07:00
parent b1cbb08eb8
commit 6ed0a1e206
2 changed files with 35 additions and 1 deletions

View File

@ -217,10 +217,17 @@ def successormarkers(ctx):
def modifysuccessors(ctx, operation):
"""Return all of the node's successors which were created as a result
of a given modification operation"""
repo = ctx.repo().filtered('visible')
for m in successormarkers(ctx):
if m.metadata().get('operation') == operation:
for node in m.succnodes():
yield nodemod.hex(node)
try:
repo[node]
except Exception:
# filtered or unknown node
pass
else:
yield nodemod.hex(node)
def sortnodes(nodes, parentfunc, masters):
"""Topologically sorts the nodes, using the parentfunc to find

View File

@ -165,3 +165,30 @@ Only nodes that were folded or rebased will have successors.
r4 a14277652442
$ hg log --hidden -r 5 -T "{desc} {histeditsuccessors % '{short(histeditsuccessor)} '}\n"
r5
Hidden changesets are not considered as successors
$ reset
$ hg debugbuilddag +2
$ hg log -T '{rev} {node|short}' -G -r 'all()'
o 1 66f7d451a68b
|
o 0 1ea73414a91b
$ hg up tip -q
$ echo 1 > a
$ hg commit --amend -m a -A a -d '1 0'
$ hg up 1 --hidden -q
$ hg log -T "{rev} {node|short} {amendsuccessors % '(amend as {short(amendsuccessor)}) '}\n" -G -r 'all()'
o 3 1ef61e92c901
|
| @ 1 66f7d451a68b (amend as 1ef61e92c901)
|/
o 0 1ea73414a91b
$ hg prune 3 -q
$ hg log -T "{rev} {node|short} {amendsuccessors % '(amend as {short(amendsuccessor)}) '}\n" -G -r 'all()'
x 1 66f7d451a68b
|
@ 0 1ea73414a91b