File: test-encoding-align

package info (click to toggle)
mercurial 1.6.4-1%2Bdeb6u1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 17,928 kB
  • ctags: 6,062
  • sloc: python: 44,238; sh: 20,985; tcl: 3,578; ansic: 2,557; lisp: 1,412; makefile: 176; xml: 15
file content (127 lines) | stat: -rwxr-xr-x 2,603 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/sh

########################################

HGENCODING=utf-8
export HGENCODING

hg init t
cd t

python << EOF
# (byte, width) = (6, 4)
s = "\xe7\x9f\xad\xe5\x90\x8d"
# (byte, width) = (7, 7): odd width is good for alignment test
m = "MIDDLE_"
# (byte, width) = (18, 12)
l = "\xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d"

f = file('s', 'w'); f.write(s); f.close()
f = file('m', 'w'); f.write(m); f.close()
f = file('l', 'w'); f.write(l); f.close()

# instant extension to show list of options
f = file('showoptlist.py', 'w'); f.write("""# encoding: utf-8
def showoptlist(ui, repo, *pats, **opts):
    '''dummy command to show option descriptions'''
    return 0

cmdtable = {
    'showoptlist':
        (showoptlist,
         [('s', 'opt1', '', 'short width',  '""" + s + """'),
          ('m', 'opt2', '', 'middle width', '""" + m + """'),
          ('l', 'opt3', '', 'long width',   '""" + l + """')
         ],
         ""
        )
}
""")
f.close()
EOF

S=`cat s`
M=`cat m`
L=`cat l`

########################################
#### alignment of:
####     - option descriptions in help

cat <<EOF > .hg/hgrc
[extensions]
ja_ext = `pwd`/showoptlist.py
EOF
echo '% check alignment of option descriptions in help'
hg help showoptlist

########################################
#### alignment of:
####     - user names in annotate
####     - file names in diffstat

rm -f s; touch s
rm -f m; touch m
rm -f l; touch l

#### add files

cp s $S
hg add $S
cp m $M
hg add $M
cp l $L
hg add $L

#### commit(1)

echo 'first line(1)' >> s; cp s $S
echo 'first line(2)' >> m; cp m $M
echo 'first line(3)' >> l; cp l $L
hg commit -m 'first commit' -u $S -d "1000000 0"

#### commit(2)

echo 'second line(1)' >> s; cp s $S
echo 'second line(2)' >> m; cp m $M
echo 'second line(3)' >> l; cp l $L
hg commit -m 'second commit' -u $M -d "1000000 0"

#### commit(3)

echo 'third line(1)' >> s; cp s $S
echo 'third line(2)' >> m; cp m $M
echo 'third line(3)' >> l; cp l $L
hg commit -m 'third commit' -u $L -d "1000000 0"

#### check

echo '% check alignment of user names in annotate'
hg annotate -u $M
echo '% check alignment of filenames in diffstat'
hg diff -c tip --stat

########################################
#### alignment of:
####     - branch names in list
####     - tag names in list

#### add branches/tags

hg branch $S
hg tag -d "1000000 0" $S
hg branch $M
hg tag -d "1000000 0" $M
hg branch $L
hg tag -d "1000000 0" $L

#### check

echo '% check alignment of branches'
hg tags
echo '% check alignment of tags'
hg tags

########################################

exit 0