changeset 4657:c24dabf8e848

stack: handle hash sizes when --debug flag is provided Since showstack() now uses fm.hexfunc() for node hashes, which depends on ui.debugflag, we should handle situations when hashes are full-sized as well.
author Anton Shestakov <av6@dwimlabs.net>
date Sat, 18 May 2019 16:56:47 +0800
parents dbf676c86244
children 89c1b739fabe
files hgext3rd/topic/stack.py tests/test-topic-stack.t
diffstat 2 files changed, 25 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/stack.py	Fri May 17 17:50:25 2019 +0800
+++ b/hgext3rd/topic/stack.py	Sat May 18 16:56:47 2019 +0800
@@ -358,9 +358,16 @@
         fm.data(isentry=isentry)
 
         if idx is None:
-            fm.plain('  ')
+            spacewidth = 0
             if ui.verbose:
-                fm.plain('              ')
+                # parentheses plus short node hash
+                spacewidth = 2 + 12
+            if ui.debugflag:
+                # parentheses plus full node hash
+                spacewidth = 2 + 40
+            # s# alias width
+            spacewidth += 2
+            fm.plain(' ' * spacewidth)
         else:
             fm.write('stack_index', '%s%%d' % prefix, idx,
                      label=labelsgen('topic.stack.index', states))
--- a/tests/test-topic-stack.t	Fri May 17 17:50:25 2019 +0800
+++ b/tests/test-topic-stack.t	Sat May 18 16:56:47 2019 +0800
@@ -628,6 +628,22 @@
   s1: c_D
   s0^ c_c (base)
 
+  $ hg stack -v
+  ### topic: foobar
+  ### target: default (branch), 3 behind
+  s2(ea0f882ce093)@ c_e (current)
+                  ^ c_h
+  s1(d2f548af67ab): c_D
+  s0(8522f9e3fee9)^ c_c (base)
+
+  $ hg stack --debug
+  ### topic: foobar
+  ### target: default (branch), 3 behind
+  s2(ea0f882ce093a2ad63db49083c5cb98a24a9470e)@ c_e (current)
+                                              ^ c_h
+  s1(d2f548af67ab55b08452a3e00a539319490fcd5b): c_D
+  s0(8522f9e3fee92d4ec4e688ac3fbd2ee0f8fd5036)^ c_c (base)
+
   $ hg stack foo
   ### topic: foo
   ### target: default (branch), ambiguous rebase destination - topic 'foo' has 3 heads