changeset 3080:30f6030dca8f

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
author Aurélien Campéas
date Tue, 26 Sep 2017 12:27:43 +0200
parents c0de0010ec30
children f63c97c01f92
files hgext3rd/topic/__init__.py tests/test-topic-fold.t tests/test-topic-tutorial.t tests/test-topic.t
diffstat 4 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py
+++ b/hgext3rd/topic/__init__.py
@@ -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()
--- a/tests/test-topic-fold.t
+++ b/tests/test-topic-fold.t
@@ -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
--- a/tests/test-topic-tutorial.t
+++ b/tests/test-topic-tutorial.t
@@ -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
 
--- a/tests/test-topic.t
+++ b/tests/test-topic.t
@@ -490,6 +490,7 @@
 disappear:
 
   $ hg topics --clear
+  clearing empty topic "query"
   $ hg topics
      fran