topics: show working directory branch when topic is empty
authorPulkit Goyal <7895pulkit@gmail.com>
Fri, 15 Sep 2017 22:48:55 +0530
changeset 2936 3a9303b7b648
parent 2935 6f7f8c6fcfb0
child 2937 b54abc7e80e2
topics: show working directory branch when topic is empty
hgext3rd/topic/stack.py
tests/test-topic-stack.t
tests/test-topic.t
--- a/hgext3rd/topic/stack.py	Fri Sep 01 15:09:59 2017 +0530
+++ b/hgext3rd/topic/stack.py	Fri Sep 15 22:48:55 2017 +0530
@@ -169,7 +169,10 @@
 
     @util.propertycache
     def branches(self):
-        return sorted(set(self._repo[r].branch() for r in self._revs))
+        branches = sorted(set(self._repo[r].branch() for r in self._revs))
+        if not branches:
+            branches = set([self._repo[None].branch()])
+        return branches
 
 def labelsgen(prefix, labelssuffix):
     """ Takes a label prefix and a list of suffixes. Returns a string of the prefix
--- a/tests/test-topic-stack.t	Fri Sep 01 15:09:59 2017 +0530
+++ b/tests/test-topic-stack.t	Fri Sep 15 22:48:55 2017 +0530
@@ -66,7 +66,7 @@
    * other
   $ hg stack
   ### topic: other
-  ### branch: 
+  ### branch: default
 
   $ hg up foo
   switching to topic foo
@@ -224,7 +224,7 @@
 
   $ hg topic --clear
   $ hg stack
-  ### branch: 
+  ### branch: default
 
 Test "t#" reference
 -------------------
--- a/tests/test-topic.t	Fri Sep 01 15:09:59 2017 +0530
+++ b/tests/test-topic.t	Fri Sep 15 22:48:55 2017 +0530
@@ -139,10 +139,10 @@
   $ hg topics
    * narf
   $ hg topics -v
-   * narf (on branch: , 0 changesets)
+   * narf (on branch: default, 0 changesets)
   $ hg stack
   ### topic: narf
-  ### branch: 
+  ### branch: default
 
 Add commits to topic