##// END OF EJS Templates
help: search section of help topic by translated section name correctly...
FUJIWARA Katsunori -
r29155:aaabed77 3.8.2 stable
parent child Browse files
Show More
@@ -4590,7 +4590,7 b' def help_(ui, name=None, **opts):'
4590 subtopic = None
4590 subtopic = None
4591 if name and '.' in name:
4591 if name and '.' in name:
4592 name, section = name.split('.', 1)
4592 name, section = name.split('.', 1)
4593 section = section.lower()
4593 section = encoding.lower(section)
4594 if '.' in section:
4594 if '.' in section:
4595 subtopic, section = section.split('.', 1)
4595 subtopic, section = section.split('.', 1)
4596 else:
4596 else:
@@ -724,7 +724,7 b' def getsections(blocks):'
724 x = b['key']
724 x = b['key']
725 else:
725 else:
726 x = b['lines'][0]
726 x = b['lines'][0]
727 x = x.lower().strip('"')
727 x = encoding.lower(x).strip('"')
728 if '(' in x:
728 if '(' in x:
729 x = x.split('(')[0]
729 x = x.split('(')[0]
730 return x
730 return x
@@ -1524,6 +1524,78 b' Test section lookup'
1524 files List of strings. All files modified, added, or removed by
1524 files List of strings. All files modified, added, or removed by
1525 this changeset.
1525 this changeset.
1526
1526
1527 Test section lookup by translated message
1528
1529 str.lower() instead of encoding.lower(str) on translated message might
1530 make message meaningless, because some encoding uses 0x41(A) - 0x5a(Z)
1531 as the second or later byte of multi-byte character.
1532
1533 For example, "\x8bL\x98^" (translation of "record" in ja_JP.cp932)
1534 contains 0x4c (L). str.lower() replaces 0x4c(L) by 0x6c(l) and this
1535 replacement makes message meaningless.
1536
1537 This tests that section lookup by translated string isn't broken by
1538 such str.lower().
1539
1540 $ python <<EOF
1541 > def escape(s):
1542 > return ''.join('\u%x' % ord(uc) for uc in s.decode('cp932'))
1543 > # translation of "record" in ja_JP.cp932
1544 > upper = "\x8bL\x98^"
1545 > # str.lower()-ed section name should be treated as different one
1546 > lower = "\x8bl\x98^"
1547 > with open('ambiguous.py', 'w') as fp:
1548 > fp.write("""# ambiguous section names in ja_JP.cp932
1549 > u'''summary of extension
1550 >
1551 > %s
1552 > ----
1553 >
1554 > Upper name should show only this message
1555 >
1556 > %s
1557 > ----
1558 >
1559 > Lower name should show only this message
1560 >
1561 > subsequent section
1562 > ------------------
1563 >
1564 > This should be hidden at "hg help ambiguous" with section name.
1565 > '''
1566 > """ % (escape(upper), escape(lower)))
1567 > EOF
1568
1569 $ cat >> $HGRCPATH <<EOF
1570 > [extensions]
1571 > ambiguous = ./ambiguous.py
1572 > EOF
1573
1574 $ python <<EOF | sh
1575 > upper = "\x8bL\x98^"
1576 > print "hg --encoding cp932 help -e ambiguous.%s" % upper
1577 > EOF
1578 \x8bL\x98^ (esc)
1579 ----
1580
1581 Upper name should show only this message
1582
1583
1584 $ python <<EOF | sh
1585 > lower = "\x8bl\x98^"
1586 > print "hg --encoding cp932 help -e ambiguous.%s" % lower
1587 > EOF
1588 \x8bl\x98^ (esc)
1589 ----
1590
1591 Lower name should show only this message
1592
1593
1594 $ cat >> $HGRCPATH <<EOF
1595 > [extensions]
1596 > ambiguous = !
1597 > EOF
1598
1527 Test dynamic list of merge tools only shows up once
1599 Test dynamic list of merge tools only shows up once
1528 $ hg help merge-tools
1600 $ hg help merge-tools
1529 Merge Tools
1601 Merge Tools
General Comments 0
You need to be logged in to leave comments. Login now