# HG changeset patch # User Denis Laxalde # Date 1527070584 -7200 # Node ID eb928f5728c4268455cb8bed0ce61daacac404df # Parent 1bc4b0807c37d9147816b94d97b9e82b7f90c630 topic: suggest to clear a topic that becomes empty We add a hint suggesting "hg topic --clear" when a topic becomes empty. This usually happens when all its changesets get public, that is when the user does a 'phase -p' or when they pull from a server. To discriminate relevant cases for which we should display the hint (and typically exclude explicit 'hg topic --clear' operation), we look for the transaction "type" to only consider 'phase' or 'push' transaction. In the latter case, the transaction name is not simply 'push-response' but it also included the remote URL so we need to match on string content. diff -r 1bc4b0807c37 -r eb928f5728c4 hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py Wed May 23 11:37:37 2018 +0200 +++ b/hgext3rd/topic/__init__.py Wed May 23 12:16:24 2018 +0200 @@ -487,6 +487,9 @@ empty = csetcount == 0 if empty and not ctwasempty: ui.status('active topic %r is now empty\n' % ct) + if ('phase' in tr.names + or any(n.startswith('push-response') for n in tr.names)): + ui.status(_("(use 'hg topic --clear' to clear it if needed)\n")) hint = _("(see 'hg help topics' for more information)\n") if ctwasempty and not empty: if csetcount == 1: diff -r 1bc4b0807c37 -r eb928f5728c4 tests/test-topic-flow-publish-flag.t --- a/tests/test-topic-flow-publish-flag.t Wed May 23 11:37:37 2018 +0200 +++ b/tests/test-topic-flow-publish-flag.t Wed May 23 12:16:24 2018 +0200 @@ -300,6 +300,7 @@ adding file changes added 1 changesets with 1 changes to 1 files active topic 'topic_A' is now empty + (use 'hg topic --clear' to clear it if needed) $ hg log --rev 'sort(all(), "topo")' -GT '{rev}:{node|short} {desc} {phase} {branch} {topics}' @ 11:d06fc4f891e8 c_dK0 public default | diff -r 1bc4b0807c37 -r eb928f5728c4 tests/test-topic-mode.t --- a/tests/test-topic-mode.t Wed May 23 11:37:37 2018 +0200 +++ b/tests/test-topic-mode.t Wed May 23 12:16:24 2018 +0200 @@ -244,6 +244,7 @@ $ hg phase --public -r . active topic 'various-dove' is now empty + (use 'hg topic --clear' to clear it if needed) $ hg up default clearing empty topic "various-dove" 0 files updated, 0 files merged, 0 files removed, 0 files unresolved @@ -307,6 +308,7 @@ $ hg phase --public -r . active topic 'various-dove' is now empty + (use 'hg topic --clear' to clear it if needed) $ hg up default clearing empty topic "various-dove" 0 files updated, 0 files merged, 0 files removed, 0 files unresolved diff -r 1bc4b0807c37 -r eb928f5728c4 tests/test-topic-stack.t --- a/tests/test-topic-stack.t Wed May 23 11:37:37 2018 +0200 +++ b/tests/test-topic-stack.t Wed May 23 12:16:24 2018 +0200 @@ -64,6 +64,7 @@ t1: c_a $ hg phase --public 'topic("other")' active topic 'other' is now empty + (use 'hg topic --clear' to clear it if needed) After changing the phase of all the changesets in "other" to public, the topic should still be active, but is empty. We should be better at informating the user about it and displaying good data in this case. diff -r 1bc4b0807c37 -r eb928f5728c4 tests/test-topic-tutorial.t --- a/tests/test-topic-tutorial.t Wed May 23 11:37:37 2018 +0200 +++ b/tests/test-topic-tutorial.t Wed May 23 12:16:24 2018 +0200 @@ -602,6 +602,7 @@ added 2 changesets with 2 changes to 1 files 2 new obsolescence markers active topic 'food' is now empty + (use 'hg topic --clear' to clear it if needed) $ hg topics * food (0 changesets) diff -r 1bc4b0807c37 -r eb928f5728c4 tests/test-topic.t --- a/tests/test-topic.t Wed May 23 11:37:37 2018 +0200 +++ b/tests/test-topic.t Wed May 23 12:16:24 2018 +0200 @@ -535,6 +535,7 @@ tip $ hg phase --public narf active topic 'narf' is now empty + (use 'hg topic --clear' to clear it if needed) POSSIBLE BUG: narf topic stays alive even though we just made all narf commits public: