Mercurial > hg
comparison mercurial/revsetlang.py @ 35595:91201737d07a
revsetlang: fix quoting of %ls string
Before, "'" wasn't escaped appropriately. This also changes the separator
'\0' to '\\0', but that's okay as a string token is unescaped.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 01 Apr 2017 17:51:56 +0900 |
parents | 468d7a1f6633 |
children | a57acea31b3b |
comparison
equal
deleted
inserted
replaced
35594:468d7a1f6633 | 35595:91201737d07a |
---|---|
583 >>> b = lambda: b'default' | 583 >>> b = lambda: b'default' |
584 >>> b.branch = b | 584 >>> b.branch = b |
585 >>> formatspec(b'branch(%b)', b) | 585 >>> formatspec(b'branch(%b)', b) |
586 "branch('default')" | 586 "branch('default')" |
587 >>> formatspec(b'root(%ls)', [b'a', b'b', b'c', b'd']) | 587 >>> formatspec(b'root(%ls)', [b'a', b'b', b'c', b'd']) |
588 "root(_list('a\\x00b\\x00c\\x00d'))" | 588 "root(_list('a\\\\x00b\\\\x00c\\\\x00d'))" |
589 >>> formatspec('%ls', ['a', "'"]) | |
590 "_list('a\\\\x00\\\\'')" | |
589 ''' | 591 ''' |
590 | 592 |
591 def argtype(c, arg): | 593 def argtype(c, arg): |
592 if c == 'd': | 594 if c == 'd': |
593 return '%d' % int(arg) | 595 return '%d' % int(arg) |
612 elif l == 1: | 614 elif l == 1: |
613 return argtype(t, s[0]) | 615 return argtype(t, s[0]) |
614 elif t == 'd': | 616 elif t == 'd': |
615 return "_intlist('%s')" % "\0".join('%d' % int(a) for a in s) | 617 return "_intlist('%s')" % "\0".join('%d' % int(a) for a in s) |
616 elif t == 's': | 618 elif t == 's': |
617 return "_list('%s')" % "\0".join(s) | 619 return "_list(%s)" % _quote("\0".join(s)) |
618 elif t == 'n': | 620 elif t == 'n': |
619 return "_hexlist('%s')" % "\0".join(node.hex(a) for a in s) | 621 return "_hexlist('%s')" % "\0".join(node.hex(a) for a in s) |
620 elif t == 'b': | 622 elif t == 'b': |
621 try: | 623 try: |
622 return "_list('%s')" % "\0".join(a.branch() for a in s) | 624 return "_list('%s')" % "\0".join(a.branch() for a in s) |