changeset 21571:17da326fd041 stable

bookmarks: properly align multi-byte characters
author Matt Mackall <mpm@selenic.com>
date Tue, 27 May 2014 15:16:52 -0700
parents d0ec3800101a
children 6c9b7712ac69
files mercurial/commands.py tests/test-encoding-align.t
diffstat 2 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Tue May 27 15:13:13 2014 -0700
+++ b/mercurial/commands.py	Tue May 27 15:16:52 2014 -0700
@@ -951,8 +951,9 @@
                 if ui.quiet:
                     ui.write("%s\n" % bmark, label=label)
                 else:
-                    ui.write(" %s %-25s %d:%s\n" % (
-                        prefix, bmark, repo.changelog.rev(n), hexfn(n)),
+                    pad = " " * (25 - encoding.colwidth(bmark))
+                    ui.write(" %s %s%s %d:%s\n" % (
+                        prefix, bmark, pad, repo.changelog.rev(n), hexfn(n)),
                         label=label)
 
 @command('branch',
--- a/tests/test-encoding-align.t	Tue May 27 15:13:13 2014 -0700
+++ b/tests/test-encoding-align.t	Tue May 27 15:16:52 2014 -0700
@@ -117,14 +117,17 @@
   marked working directory as branch \xe7\x9f\xad\xe5\x90\x8d (esc)
   (branches are permanent and global, did you want a bookmark?)
   $ hg tag $S
+  $ hg book -f $S
   $ hg branch $M
   marked working directory as branch MIDDLE_
   (branches are permanent and global, did you want a bookmark?)
   $ hg tag $M
+  $ hg book -f $M
   $ hg branch $L
   marked working directory as branch \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d (esc)
   (branches are permanent and global, did you want a bookmark?)
   $ hg tag $L
+  $ hg book -f $L
 
 check alignment of branches
 
@@ -142,4 +145,9 @@
   MIDDLE_                            3:b06c5b6def9e
   \xe7\x9f\xad\xe5\x90\x8d                               2:64a70663cee8 (esc)
 
-  $ cd ..
+check alignment of bookmarks
+
+  $ hg book
+     MIDDLE_                   5:d745ff46155b
+     \xe7\x9f\xad\xe5\x90\x8d                      4:9259be597f19 (esc)
+   * \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d              5:d745ff46155b (esc)