stack: handle external-children just like other states
authorAnton Shestakov <av6@dwimlabs.net>
Sat, 09 Mar 2019 12:54:00 +0800
changeset 4434 432f2155d106
parent 4433 a19d8196b0c9
child 4435 7915aef191ff
stack: handle external-children just like other states This also fixes color labels: previously when external-children was combined with another state, --color=debug would show something like: [topic.stack.index topic.stack.index.current - external-children|s4] Now there is a separate label for each state.
hgext3rd/topic/stack.py
--- a/hgext3rd/topic/stack.py	Thu Mar 07 22:50:56 2019 +0800
+++ b/hgext3rd/topic/stack.py	Sat Mar 09 12:54:00 2019 +0800
@@ -321,27 +321,20 @@
 
         symbol = None
         states = []
-        msg = ''
         iscurrentrevision = repo.revs('%d and parents()', ctx.rev())
         if opts.get('children'):
             expr = 'children(%d) and merge() - %ld'
             revisions = repo.revs(expr, ctx.rev(), st.revs[1:])
             if len(revisions) > 0:
-                msg = 'external-children'
+                states.append('external-children')
 
         if iscurrentrevision:
             symbol = '@'
-            if msg:
-                states.append('current - ' + msg)
-            else:
-                states.append('current')
+            states.append('current')
 
         if ctx.orphan():
             symbol = '$'
-            if msg:
-                states.append('orphan - ' + msg)
-            else:
-                states.append('orphan')
+            states.append('orphan')
 
         if not isentry:
             symbol = '^'
@@ -351,10 +344,9 @@
         # none of the above if statments get executed
         if not symbol:
             symbol = ':'
-            if msg:
-                states.append(msg)
-            else:
-                states.append('clean')
+
+        if not states:
+            states.append('clean')
 
         states.sort()