diff hgext3rd/topic/__init__.py @ 2985:f63c97c01f92

topics/ui: signal when the topics command creates a new (empty) topic
author Aur?lien Camp?as
date Tue, 26 Sep 2017 12:29:15 +0200
parents 30f6030dca8f
children 4746b92cc1f8
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py	Tue Sep 26 12:27:43 2017 +0200
+++ b/hgext3rd/topic/__init__.py	Tue Sep 26 12:29:15 2017 +0200
@@ -437,8 +437,8 @@
             repo.invalidate()
         return
 
+    ct = repo.currenttopic
     if clear:
-        ct = repo.currenttopic
         empty = stack.stackdata(repo, topic=ct)['changesetcount'] == 0
         if empty:
             if ct:
@@ -446,11 +446,13 @@
         return _changecurrenttopic(repo, None)
 
     if topic:
+        if not ct:
+            ui.status(_('marked working directory as topic: %s\n') % topic)
         return _changecurrenttopic(repo, topic)
 
     # `hg topic --current`
     ret = 0
-    if current and not repo.currenttopic:
+    if current and not ct:
         ui.write_err(_('no active topic\n'))
         ret = 1
     elif current:
@@ -458,7 +460,7 @@
         namemask = '%s\n'
         label = 'topic.active'
         fm.startitem()
-        fm.write('topic', namemask, repo.currenttopic, label=label)
+        fm.write('topic', namemask, ct, label=label)
         fm.end()
     else:
         _listtopics(ui, repo, opts)