bookmarks: properly align multi-byte characters stable
authorMatt Mackall <mpm@selenic.com>
Tue, 27 May 2014 15:16:52 -0700
branchstable
changeset 21571 17da326fd041
parent 21570 d0ec3800101a
child 21572 6c9b7712ac69
bookmarks: properly align multi-byte characters
mercurial/commands.py
tests/test-encoding-align.t
--- 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)