Patchwork [4,of,5,topic-experiment] stack: show unstable state for the current revision if it is one (issue5553)

login
register
mail settings
Submitter Pulkit Goyal
Date June 18, 2017, 10:12 p.m.
Message ID <83df91589000c0535980.1497823943@workspace>
Download mbox | patch
Permalink /patch/21493/
State Accepted
Headers show

Comments

Pulkit Goyal - June 18, 2017, 10:12 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1497820835 -19800
#      Mon Jun 19 02:50:35 2017 +0530
# Node ID 83df91589000c05359805c96fa84a3995896ee3c
# Parent  46b090ecd2b9f69f52cae756008f199f78bb22c1
stack: show unstable state for the current revision if it is one (issue5553)

Before this patch if the current revision is unstable, hg stack does not show
the unstable state. This patch fixes that by showing both current and unstable
state for the current revision if that's unstable.

Patch

diff --git a/hgext3rd/topic/stack.py b/hgext3rd/topic/stack.py
--- a/hgext3rd/topic/stack.py
+++ b/hgext3rd/topic/stack.py
@@ -69,19 +69,22 @@ 
         states = []
         iscurrentrevision = repo.revs('%d and parents()', ctx.rev())
 
-        if iscurrentrevision:
-            states.append('current')
-
         if not isentry:
             symbol = '^'
             # "base" is kind of a "ghost" entry
             # skip other label for them (no current, no unstable)
             states = ['base']
-        elif iscurrentrevision:
-            symbol = '@'
         elif repo.revs('%d and unstable()', ctx.rev()):
             symbol = '$'
             states.append('unstable')
+            # current revision can be unstable also, so in that case show both
+            # the states and the symbol '@' (issue5553)
+            if iscurrentrevision:
+                states.append('current')
+                symbol = '@'
+        elif iscurrentrevision:
+            states.append('current')
+            symbol = '@'
         else:
             symbol = ':'
             states.append('clean')
diff --git a/tests/test-topic-stack.t b/tests/test-topic-stack.t
--- a/tests/test-topic-stack.t
+++ b/tests/test-topic-stack.t
@@ -188,7 +188,7 @@ 
   ### topic: foo
   ### branch: default
   t4$ c_f (unstable)
-  t3@ c_e (current)
+  t3@ c_e (unstable current)
   t2: c_d
   t1: c_c
     ^ c_b
@@ -196,7 +196,7 @@ 
   [topic.stack.summary.topic|### topic: [topic.active|foo]]
   [topic.stack.summary.branches|### branch: default]
   [topic.stack.index topic.stack.index.unstable|t4][topic.stack.state topic.stack.state.unstable|$] [topic.stack.desc topic.stack.desc.unstable|c_f][topic.stack.state topic.stack.state.unstable| (unstable)]
-  [topic.stack.index topic.stack.index.current|t3][topic.stack.state topic.stack.state.current|@] [topic.stack.desc topic.stack.desc.current|c_e][topic.stack.state topic.stack.state.current| (current)]
+  [topic.stack.index topic.stack.index.unstable topic.stack.index.current|t3][topic.stack.state topic.stack.state.unstable topic.stack.state.current|@] [topic.stack.desc topic.stack.desc.unstable topic.stack.desc.current|c_e][topic.stack.state topic.stack.state.unstable topic.stack.state.current| (unstable current)]
   [topic.stack.index topic.stack.index.clean|t2][topic.stack.state topic.stack.state.clean|:] [topic.stack.desc topic.stack.desc.clean|c_d]
   [topic.stack.index topic.stack.index.clean|t1][topic.stack.state topic.stack.state.clean|:] [topic.stack.desc topic.stack.desc.clean|c_c]
     [topic.stack.state topic.stack.state.base|^] [topic.stack.desc topic.stack.desc.base|c_b]