hgext3rd/topic/__init__.py
changeset 4044 c0fbe70f2e48
parent 4038 36225eb4d307
child 4065 fbc51e98cf13
--- a/hgext3rd/topic/__init__.py	Wed Aug 29 18:59:07 2018 +0200
+++ b/hgext3rd/topic/__init__.py	Tue Aug 28 21:28:41 2018 +0800
@@ -644,9 +644,9 @@
 
     ct = repo.currenttopic
     if clear:
-        empty = stack.stack(repo, topic=ct).changesetcount == 0
-        if empty:
-            if ct:
+        if ct:
+            empty = stack.stack(repo, topic=ct).changesetcount == 0
+            if empty:
                 ui.status(_('clearing empty topic "%s"\n') % ct)
         return _changecurrenttopic(repo, None)
 
@@ -1149,7 +1149,6 @@
         # rebased commit. We have explicitly stored in config if rebase is
         # running.
         ot = repo.currenttopic
-        empty = stack.stack(repo, topic=ot).changesetcount == 0
         if repo.ui.hasconfig('experimental', 'topicrebase'):
             isrebase = True
         if repo.ui.configbool('_internal', 'keep-topic'):
@@ -1163,8 +1162,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)
+            if ot and not t:
+                empty = stack.stack(repo, topic=ot).changesetcount == 0
+                if empty:
+                    repo.ui.status(_('clearing empty topic "%s"\n') % ot)
         elif ist0:
             repo.ui.status(_("preserving the current topic '%s'\n") % ot)
         return ret