tests/test-encoding-align.t
changeset 12418 09c6dd129f82
parent 12156 4c94b6d0fb1c
child 12722 22f45e53bb21
equal deleted inserted replaced
12417:1aba1c38a85b 12418:09c6dd129f82
       
     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   > # (byte, width) = (6, 4)
       
     9   > s = "\xe7\x9f\xad\xe5\x90\x8d"
       
    10   > # (byte, width) = (7, 7): odd width is good for alignment test
       
    11   > m = "MIDDLE_"
       
    12   > # (byte, width) = (18, 12)
       
    13   > l = "\xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d"
       
    14   > f = file('s', 'w'); f.write(s); f.close()
       
    15   > f = file('m', 'w'); f.write(m); f.close()
       
    16   > f = file('l', 'w'); f.write(l); f.close()
       
    17   > # instant extension to show list of options
       
    18   > f = file('showoptlist.py', 'w'); f.write("""# encoding: utf-8
       
    19   > def showoptlist(ui, repo, *pats, **opts):
       
    20   >     '''dummy command to show option descriptions'''
       
    21   >     return 0
       
    22   > cmdtable = {
       
    23   >     'showoptlist':
       
    24   >         (showoptlist,
       
    25   >          [('s', 'opt1', '', 'short width',  '""" + s + """'),
       
    26   >           ('m', 'opt2', '', 'middle width', '""" + m + """'),
       
    27   >           ('l', 'opt3', '', 'long width',   '""" + l + """')
       
    28   >          ],
       
    29   >          ""
       
    30   >         )
       
    31   > }
       
    32   > """)
       
    33   > f.close()
       
    34   > EOF
       
    35   $ S=`cat s`
       
    36   $ M=`cat m`
       
    37   $ L=`cat l`
       
    38 
       
    39 alignment of option descriptions in help
       
    40 
       
    41   $ cat <<EOF > .hg/hgrc
       
    42   > [extensions]
       
    43   > ja_ext = `pwd`/showoptlist.py
       
    44   > EOF
       
    45 
       
    46 check alignment of option descriptions in help
       
    47 
       
    48   $ hg help showoptlist
       
    49   hg showoptlist 
       
    50   
       
    51   dummy command to show option descriptions
       
    52   
       
    53   options:
       
    54   
       
    55    -s --opt1 短名          short width
       
    56    -m --opt2 MIDDLE_       middle width
       
    57    -l --opt3 長い長い名前  long width
       
    58   
       
    59   use "hg -v help showoptlist" to show global options
       
    60 
       
    61 
       
    62   $ rm -f s; touch s
       
    63   $ rm -f m; touch m
       
    64   $ rm -f l; touch l
       
    65 
       
    66 add files
       
    67 
       
    68   $ cp s $S
       
    69   $ hg add $S
       
    70   $ cp m $M
       
    71   $ hg add $M
       
    72   $ cp l $L
       
    73   $ hg add $L
       
    74 
       
    75 commit(1)
       
    76 
       
    77   $ echo 'first line(1)' >> s; cp s $S
       
    78   $ echo 'first line(2)' >> m; cp m $M
       
    79   $ echo 'first line(3)' >> l; cp l $L
       
    80   $ hg commit -m 'first commit' -u $S
       
    81 
       
    82 commit(2)
       
    83 
       
    84   $ echo 'second line(1)' >> s; cp s $S
       
    85   $ echo 'second line(2)' >> m; cp m $M
       
    86   $ echo 'second line(3)' >> l; cp l $L
       
    87   $ hg commit -m 'second commit' -u $M
       
    88 
       
    89 commit(3)
       
    90 
       
    91   $ echo 'third line(1)' >> s; cp s $S
       
    92   $ echo 'third line(2)' >> m; cp m $M
       
    93   $ echo 'third line(3)' >> l; cp l $L
       
    94   $ hg commit -m 'third commit' -u $L
       
    95 
       
    96 check alignment of user names in annotate
       
    97 
       
    98   $ hg annotate -u $M
       
    99           短名: first line(2)
       
   100        MIDDLE_: second line(2)
       
   101   長い長い名前: third line(2)
       
   102 
       
   103 check alignment of filenames in diffstat
       
   104 
       
   105   $ hg diff -c tip --stat
       
   106    MIDDLE_      |  1 +
       
   107    短名         |  1 +
       
   108    長い長い名前 |  1 +
       
   109    3 files changed, 3 insertions(+), 0 deletions(-)
       
   110 
       
   111 add branches/tags
       
   112 
       
   113   $ hg branch $S
       
   114   marked working directory as branch 短名
       
   115   $ hg tag $S
       
   116   $ hg branch $M
       
   117   marked working directory as branch MIDDLE_
       
   118   $ hg tag $M
       
   119   $ hg branch $L
       
   120   marked working directory as branch 長い長い名前
       
   121   $ hg tag $L
       
   122 
       
   123 check alignment of branches
       
   124 
       
   125   $ hg tags
       
   126   tip                                5:d745ff46155b
       
   127   長い長い名前                       4:9259be597f19
       
   128   MIDDLE_                            3:b06c5b6def9e
       
   129   短名                               2:64a70663cee8
       
   130 
       
   131 check alignment of tags
       
   132 
       
   133   $ hg tags
       
   134   tip                                5:d745ff46155b
       
   135   長い長い名前                       4:9259be597f19
       
   136   MIDDLE_                            3:b06c5b6def9e
       
   137   短名                               2:64a70663cee8