changeset 1906:5e9ce6310720

stack: show the currently active changeset and unstable ones Still super basic, but give a basic idea of the feature. We use both symbols and explicit text because symbols are cool but text is more explicit
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 14 Mar 2016 18:43:23 +0000
parents 3b42478ef017
children 95874e8fc5f2
files hgext3rd/topic/stack.py tests/test-topic-stack.t
diffstat 2 files changed, 19 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/stack.py	Mon Mar 14 18:40:00 2016 +0000
+++ b/hgext3rd/topic/stack.py	Mon Mar 14 18:43:23 2016 +0000
@@ -20,7 +20,21 @@
         raise error.Abort(_('no active topic to list'))
     for idx, r in enumerate(getstack(repo, topic)):
         # super crude initial version
-        l = "t%d: %s\n" % (idx, repo[r].description().splitlines()[0])
+        symbol = ':'
+        state = 'clean'
+        if repo.revs('%d and parents()', r):
+            symbol = '@'
+            state = 'current'
+        if repo.revs('%d and unstable()', r):
+            symbol = '$'
+            state = 'unstable'
+        if state == 'clean':
+            l = "t%d%s %s\n" % (idx, symbol,
+                                repo[r].description().splitlines()[0])
+        else:
+            l = "t%d%s %s (%s)\n" % (idx, symbol,
+                                     repo[r].description().splitlines()[0],
+                                     state)
         ui.write(l)
 
 # Copied from evolve 081605c2e9b6
--- a/tests/test-topic-stack.t	Mon Mar 14 18:40:00 2016 +0000
+++ b/tests/test-topic-stack.t	Mon Mar 14 18:43:23 2016 +0000
@@ -60,7 +60,7 @@
   t0: c_c
   t1: c_d
   t2: c_e
-  t3: c_f
+  t3@ c_f (current)
 
 error case, nothing to list
 
@@ -105,6 +105,6 @@
   
   $ hg topic --list
   t0: c_c
-  t1: c_d
-  t2: c_e
-  t3: c_f
+  t1@ c_d (current)
+  t2$ c_e (unstable)
+  t3$ c_f (unstable)