Mercurial > hg > mercurial-source
comparison mercurial/revsetlang.py @ 32219:f784ba187089
py3: use bytestr wrapper in revsetlang.formatspec()
This backs out 1c48a8278b2f and wraps expr by bytestr() instead.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 16 Mar 2017 21:33:25 +0900 (2017-03-16) |
parents | 1c48a8278b2f |
children | 80c8a6db450d |
comparison
equal
deleted
inserted
replaced
32218:b70407bd84d5 | 32219:f784ba187089 |
---|---|
638 return "_list('%s')" % "\0".join(a.branch() for a in s) | 638 return "_list('%s')" % "\0".join(a.branch() for a in s) |
639 | 639 |
640 m = l // 2 | 640 m = l // 2 |
641 return '(%s or %s)' % (listexp(s[:m], t), listexp(s[m:], t)) | 641 return '(%s or %s)' % (listexp(s[:m], t), listexp(s[m:], t)) |
642 | 642 |
643 expr = pycompat.bytestr(expr) | |
643 ret = '' | 644 ret = '' |
644 pos = 0 | 645 pos = 0 |
645 arg = 0 | 646 arg = 0 |
646 while pos < len(expr): | 647 while pos < len(expr): |
647 c = expr[pos:pos + 1] | 648 c = expr[pos] |
648 if c == '%': | 649 if c == '%': |
649 pos += 1 | 650 pos += 1 |
650 d = expr[pos:pos + 1] | 651 d = expr[pos] |
651 if d == '%': | 652 if d == '%': |
652 ret += d | 653 ret += d |
653 elif d in 'dsnbr': | 654 elif d in 'dsnbr': |
654 ret += argtype(d, args[arg]) | 655 ret += argtype(d, args[arg]) |
655 arg += 1 | 656 arg += 1 |
656 elif d == 'l': | 657 elif d == 'l': |
657 # a list of some type | 658 # a list of some type |
658 pos += 1 | 659 pos += 1 |
659 d = expr[pos:pos + 1] | 660 d = expr[pos] |
660 ret += listexp(list(args[arg]), d) | 661 ret += listexp(list(args[arg]), d) |
661 arg += 1 | 662 arg += 1 |
662 else: | 663 else: |
663 raise error.Abort(_('unexpected revspec format character %s') | 664 raise error.Abort(_('unexpected revspec format character %s') |
664 % d) | 665 % d) |