diff tests/test-command-template.t @ 20370:aa51392da507

template: add pad function for padding output Adds a pad template function with the following signature: pad(text, width, fillchar=' ', right=False) This uses the standard python ljust and rjust functions to produce a string that is at least a certain width. This is useful for aligning variable length strings in log output (like user names or shortest(node) output).
author Durham Goode <durham@fb.com>
date Fri, 17 Jan 2014 00:16:48 -0800
parents 9c6b86dd2ed2
children 1e43f15a647f
line wrap: on
line diff
--- a/tests/test-command-template.t	Fri Jan 17 00:10:37 2014 -0800
+++ b/tests/test-command-template.t	Fri Jan 17 00:16:48 2014 -0800
@@ -1637,3 +1637,17 @@
   $ hg log --template '{shortest(node, 10)}\n'
   d97c383ae3
   f7769ec2ab
+
+Test pad function
+
+  $ hg log --template '{pad(rev, 20)} {author|user}\n'
+  1                    test
+  0                    test
+
+  $ hg log --template '{pad(rev, 20, " ", True)} {author|user}\n'
+                     1 test
+                     0 test
+
+  $ hg log --template '{pad(rev, 20, "-", False)} {author|user}\n'
+  1------------------- test
+  0------------------- test