# HG changeset patch # User Aurélien Campéas # Date 1506421663 -7200 # Node ID 30f6030dca8fd3e5cf0f7c412132925d867fcb0c # Parent c0de0010ec30f1cdb890fb69a260c63cf9142538 topics: signal to the end user when a topic has been forgotten Situation is: * we're updating outside an empty topic. * we've cleared topics diff -r c0de0010ec30 -r 30f6030dca8f hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py Fri Sep 22 13:46:41 2017 +0200 +++ b/hgext3rd/topic/__init__.py Tue Sep 26 12:27:43 2017 +0200 @@ -438,6 +438,11 @@ return if clear: + ct = repo.currenttopic + empty = stack.stackdata(repo, topic=ct)['changesetcount'] == 0 + if empty: + if ct: + ui.status(_('clearing empty topic "%s"\n') % ct) return _changecurrenttopic(repo, None) if topic: @@ -852,12 +857,13 @@ # if rebase is running and update the currenttopic to topic of new # rebased commit. We have explicitly stored in config if rebase is # running. + ot = repo.currenttopic + empty = stack.stackdata(repo, topic=ot)['changesetcount'] == 0 if repo.ui.hasconfig('experimental', 'topicrebase'): isrebase = True if repo.ui.configbool('_internal', 'keep-topic'): ist0 = True if ((not partial and not branchmerge) or isrebase) and not ist0: - ot = repo.currenttopic t = '' pctx = repo[node] if pctx.phase() > phases.public: @@ -866,9 +872,10 @@ f.write(t) if t and t != ot: repo.ui.status(_("switching to topic %s\n") % t) + if ot and not t and empty: + repo.ui.status(_('clearing empty topic "%s"\n') % ot) elif ist0: - repo.ui.status(_("preserving the current topic '%s'\n") % - repo.currenttopic) + repo.ui.status(_("preserving the current topic '%s'\n") % ot) return ret finally: wlock.release() diff -r c0de0010ec30 -r 30f6030dca8f tests/test-topic-fold.t --- a/tests/test-topic-fold.t Fri Sep 22 13:46:41 2017 +0200 +++ b/tests/test-topic-fold.t Tue Sep 26 12:27:43 2017 +0200 @@ -89,6 +89,7 @@ topics: $ hg fold --exact -r "(tip~1)::" -m "folded 2" 2 changesets folded + clearing empty topic "myotherfeature" 0 files updated, 0 files merged, 0 files removed, 0 files unresolved $ logtopic @ 6:03da8f7238e9a4d708d6b8af402c91c68f271477 diff -r c0de0010ec30 -r 30f6030dca8f tests/test-topic-tutorial.t --- a/tests/test-topic-tutorial.t Fri Sep 22 13:46:41 2017 +0200 +++ b/tests/test-topic-tutorial.t Tue Sep 26 12:27:43 2017 +0200 @@ -681,9 +681,10 @@ and since it is commit-less, it will vanish. $ hg update default + clearing empty topic "food" 0 files updated, 0 files merged, 0 files removed, 0 files unresolved -From there, the topic has vanished. +From there, the topic has been completely forgotten. $ hg topics diff -r c0de0010ec30 -r 30f6030dca8f tests/test-topic.t --- a/tests/test-topic.t Fri Sep 22 13:46:41 2017 +0200 +++ b/tests/test-topic.t Tue Sep 26 12:27:43 2017 +0200 @@ -490,6 +490,7 @@ disappear: $ hg topics --clear + clearing empty topic "query" $ hg topics fran