From 6ed0a1e206ff7283106b51a2e561092d8a53d4a7 Mon Sep 17 00:00:00 2001 From: Jun Wu Date: Wed, 19 Jul 2017 10:43:01 -0700 Subject: [PATCH] smartlog: only count visible successors Invisible successors could be confusing. Therefore only show visible successors. Differential Revision: https://phab.mercurial-scm.org/D149 --- hgext3rd/smartlog.py | 9 ++++++++- tests/test-smartlog-obsolete.t | 27 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/hgext3rd/smartlog.py b/hgext3rd/smartlog.py index 9dd7499d07..db42a4f191 100644 --- a/hgext3rd/smartlog.py +++ b/hgext3rd/smartlog.py @@ -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 diff --git a/tests/test-smartlog-obsolete.t b/tests/test-smartlog-obsolete.t index 45a66fbfa6..39f8aebb35 100644 --- a/tests/test-smartlog-obsolete.t +++ b/tests/test-smartlog-obsolete.t @@ -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 +