Debian Codegraph @

tests/test-encoding-align.t

raw
1 Test alignment of multibyte characters
2
3 $ HGENCODING=utf-8
4 $ export HGENCODING
5 $ hg init t
6 $ cd t
7 $ "$PYTHON" << EOF
8 > from mercurial import pycompat
9 > # (byte, width) = (6, 4)
10 > s = b"\xe7\x9f\xad\xe5\x90\x8d"
11 > # (byte, width) = (7, 7): odd width is good for alignment test
12 > m = b"MIDDLE_"
13 > # (byte, width) = (18, 12)
14 > l = b"\xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d"
15 > f = open('s', 'wb'); f.write(s); f.close()
16 > f = open('m', 'wb'); f.write(m); f.close()
17 > f = open('l', 'wb'); f.write(l); f.close()
18 > # instant extension to show list of options
19 > f = open('showoptlist.py', 'wb'); f.write(b"""# encoding: utf-8
20 > from mercurial import registrar
21 > cmdtable = {}
22 > command = registrar.command(cmdtable)
23 >
24 > @command(b'showoptlist',
25 > [(b's', b'opt1', b'', b'short width' + (b' ' +%(s)s) * 8, %(s)s),
26 > (b'm', b'opt2', b'', b'middle width' + (b' ' + %(m)s) * 8, %(m)s),
27 > (b'l', b'opt3', b'', b'long width' + (b' ' + %(l)s) * 8, %(l)s)],
28 > b'')
29 > def showoptlist(ui, repo, *pats, **opts):
30 > '''dummy command to show option descriptions'''
31 > return 0
32 > """ % {b's': pycompat.byterepr(s),
33 > b'm': pycompat.byterepr(m),
34 > b'l': pycompat.byterepr(l),
35 > })
36 > f.close()
37 > EOF
38 $ S=`cat s`
39 $ M=`cat m`
40 $ L=`cat l`
41
42 alignment of option descriptions in help
43
44 $ cat <<EOF > .hg/hgrc
45 > [extensions]
46 > ja_ext = `pwd`/showoptlist.py
47 > EOF
48
49 check alignment of option descriptions in help
50
51 $ hg help showoptlist
52 hg showoptlist
53
54 dummy command to show option descriptions
55
56 options:
57
58 -s --opt1 \xe7\x9f\xad\xe5\x90\x8d short width \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d (esc)
59 -m --opt2 MIDDLE_ middle width MIDDLE_ MIDDLE_ MIDDLE_ MIDDLE_ MIDDLE_
60 MIDDLE_ MIDDLE_ MIDDLE_
61 -l --opt3 \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d long width \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d (esc)
62 \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d (esc)
63 \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d (esc)
64
65 (some details hidden, use --verbose to show complete help)
66
67
68 $ rm -f s; touch s
69 $ rm -f m; touch m
70 $ rm -f l; touch l
71
72 add files
73
74 $ cp s $S
75 $ hg add $S
76 $ cp m $M
77 $ hg add $M
78 $ cp l $L
79 $ hg add $L
80
81 commit(1)
82
83 $ echo 'first line(1)' >> s; cp s $S
84 $ echo 'first line(2)' >> m; cp m $M
85 $ echo 'first line(3)' >> l; cp l $L
86 $ hg commit -m 'first commit' -u $S
87
88 commit(2)
89
90 $ echo 'second line(1)' >> s; cp s $S
91 $ echo 'second line(2)' >> m; cp m $M
92 $ echo 'second line(3)' >> l; cp l $L
93 $ hg commit -m 'second commit' -u $M
94
95 commit(3)
96
97 $ echo 'third line(1)' >> s; cp s $S
98 $ echo 'third line(2)' >> m; cp m $M
99 $ echo 'third line(3)' >> l; cp l $L
100 $ hg commit -m 'third commit' -u $L
101
102 check alignment of user names in annotate
103
104 $ hg annotate -u $M
105 \xe7\x9f\xad\xe5\x90\x8d: first line(2) (esc)
106 MIDDLE_: second line(2)
107 \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d: third line(2) (esc)
108
109 check alignment of filenames in diffstat
110
111 $ hg diff -c tip --stat
112 MIDDLE_ | 1 +
113 \xe7\x9f\xad\xe5\x90\x8d | 1 + (esc)
114 \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d | 1 + (esc)
115 3 files changed, 3 insertions(+), 0 deletions(-)
116
117 add branches/tags
118
119 $ hg branch $S
120 marked working directory as branch \xe7\x9f\xad\xe5\x90\x8d (esc)
121 (branches are permanent and global, did you want a bookmark?)
122 $ hg tag $S
123 $ hg book -f $S
124 $ hg branch $M
125 marked working directory as branch MIDDLE_
126 $ hg tag $M
127 $ hg book -f $M
128 $ hg branch $L
129 marked working directory as branch \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d (esc)
130 $ hg tag $L
131 $ hg book -f $L
132
133 check alignment of branches
134
135 $ hg branches
136 \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d 5:d745ff46155b (esc)
137 MIDDLE_ 4:9259be597f19 (inactive)
138 \xe7\x9f\xad\xe5\x90\x8d 3:b06c5b6def9e (inactive) (esc)
139 default 2:64a70663cee8 (inactive)
140
141 check alignment of tags
142
143 $ hg tags
144 tip 5:d745ff46155b
145 \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d 4:9259be597f19 (esc)
146 MIDDLE_ 3:b06c5b6def9e
147 \xe7\x9f\xad\xe5\x90\x8d 2:64a70663cee8 (esc)
148
149 check alignment of bookmarks
150
151 $ hg book
152 MIDDLE_ 5:d745ff46155b
153 \xe7\x9f\xad\xe5\x90\x8d 4:9259be597f19 (esc)
154 * \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d 5:d745ff46155b (esc)