tests/test-help.t
changeset 29176 8c8442523eef
parent 29162 5a3197cbe415
parent 29155 aaabed77791a
child 29413 31d3ab7985b8
equal deleted inserted replaced
29175:7bcfb9090c86 29176:8c8442523eef
  1537 
  1537 
  1538   $ hg help template.files
  1538   $ hg help template.files
  1539       files         List of strings. All files modified, added, or removed by
  1539       files         List of strings. All files modified, added, or removed by
  1540                     this changeset.
  1540                     this changeset.
  1541 
  1541 
       
  1542 Test section lookup by translated message
       
  1543 
       
  1544 str.lower() instead of encoding.lower(str) on translated message might
       
  1545 make message meaningless, because some encoding uses 0x41(A) - 0x5a(Z)
       
  1546 as the second or later byte of multi-byte character.
       
  1547 
       
  1548 For example, "\x8bL\x98^" (translation of "record" in ja_JP.cp932)
       
  1549 contains 0x4c (L). str.lower() replaces 0x4c(L) by 0x6c(l) and this
       
  1550 replacement makes message meaningless.
       
  1551 
       
  1552 This tests that section lookup by translated string isn't broken by
       
  1553 such str.lower().
       
  1554 
       
  1555   $ python <<EOF
       
  1556   > def escape(s):
       
  1557   >     return ''.join('\u%x' % ord(uc) for uc in s.decode('cp932'))
       
  1558   > # translation of "record" in ja_JP.cp932
       
  1559   > upper = "\x8bL\x98^"
       
  1560   > # str.lower()-ed section name should be treated as different one
       
  1561   > lower = "\x8bl\x98^"
       
  1562   > with open('ambiguous.py', 'w') as fp:
       
  1563   >     fp.write("""# ambiguous section names in ja_JP.cp932
       
  1564   > u'''summary of extension
       
  1565   > 
       
  1566   > %s
       
  1567   > ----
       
  1568   > 
       
  1569   > Upper name should show only this message
       
  1570   > 
       
  1571   > %s
       
  1572   > ----
       
  1573   > 
       
  1574   > Lower name should show only this message
       
  1575   > 
       
  1576   > subsequent section
       
  1577   > ------------------
       
  1578   > 
       
  1579   > This should be hidden at "hg help ambiguous" with section name.
       
  1580   > '''
       
  1581   > """ % (escape(upper), escape(lower)))
       
  1582   > EOF
       
  1583 
       
  1584   $ cat >> $HGRCPATH <<EOF
       
  1585   > [extensions]
       
  1586   > ambiguous = ./ambiguous.py
       
  1587   > EOF
       
  1588 
       
  1589   $ python <<EOF | sh
       
  1590   > upper = "\x8bL\x98^"
       
  1591   > print "hg --encoding cp932 help -e ambiguous.%s" % upper
       
  1592   > EOF
       
  1593   \x8bL\x98^ (esc)
       
  1594   ----
       
  1595   
       
  1596   Upper name should show only this message
       
  1597   
       
  1598 
       
  1599   $ python <<EOF | sh
       
  1600   > lower = "\x8bl\x98^"
       
  1601   > print "hg --encoding cp932 help -e ambiguous.%s" % lower
       
  1602   > EOF
       
  1603   \x8bl\x98^ (esc)
       
  1604   ----
       
  1605   
       
  1606   Lower name should show only this message
       
  1607   
       
  1608 
       
  1609   $ cat >> $HGRCPATH <<EOF
       
  1610   > [extensions]
       
  1611   > ambiguous = !
       
  1612   > EOF
       
  1613 
  1542 Test dynamic list of merge tools only shows up once
  1614 Test dynamic list of merge tools only shows up once
  1543   $ hg help merge-tools
  1615   $ hg help merge-tools
  1544   Merge Tools
  1616   Merge Tools
  1545   """""""""""
  1617   """""""""""
  1546   
  1618