Mercurial > public > mercurial-scm > hg
comparison mercurial/revsetlang.py @ 45942:89a2afe31e82
formating: upgrade to black 20.8b1
This required a couple of small tweaks to un-confuse black, but now it
works. Big formatting changes come from:
* Dramatically improved collection-splitting logic upstream
* Black having a strong (correct IMO) opinion that """ is better than '''
Differential Revision: https://phab.mercurial-scm.org/D9430
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Fri, 27 Nov 2020 17:03:29 -0500 |
parents | 18489e26d9a0 |
children | 59fa3890d40a |
comparison
equal
deleted
inserted
replaced
45941:346af7687c6f | 45942:89a2afe31e82 |
---|---|
81 # default set of valid characters for non-initial letters of symbols | 81 # default set of valid characters for non-initial letters of symbols |
82 _symletters = _syminitletters | set(pycompat.iterbytestr(b'-/')) | 82 _symletters = _syminitletters | set(pycompat.iterbytestr(b'-/')) |
83 | 83 |
84 | 84 |
85 def tokenize(program, lookup=None, syminitletters=None, symletters=None): | 85 def tokenize(program, lookup=None, syminitletters=None, symletters=None): |
86 ''' | 86 """ |
87 Parse a revset statement into a stream of tokens | 87 Parse a revset statement into a stream of tokens |
88 | 88 |
89 ``syminitletters`` is the set of valid characters for the initial | 89 ``syminitletters`` is the set of valid characters for the initial |
90 letter of symbols. | 90 letter of symbols. |
91 | 91 |
100 | 100 |
101 Check that @ is a valid unquoted token character (issue3686): | 101 Check that @ is a valid unquoted token character (issue3686): |
102 >>> list(tokenize(b"@::")) | 102 >>> list(tokenize(b"@::")) |
103 [('symbol', '@', 0), ('::', None, 1), ('end', None, 3)] | 103 [('symbol', '@', 0), ('::', None, 1), ('end', None, 3)] |
104 | 104 |
105 ''' | 105 """ |
106 if not isinstance(program, bytes): | 106 if not isinstance(program, bytes): |
107 raise error.ProgrammingError( | 107 raise error.ProgrammingError( |
108 b'revset statement must be bytes, got %r' % program | 108 b'revset statement must be bytes, got %r' % program |
109 ) | 109 ) |
110 program = pycompat.bytestr(program) | 110 program = pycompat.bytestr(program) |
619 alias.warned = True | 619 alias.warned = True |
620 return tree | 620 return tree |
621 | 621 |
622 | 622 |
623 def foldconcat(tree): | 623 def foldconcat(tree): |
624 """Fold elements to be concatenated by `##` | 624 """Fold elements to be concatenated by `##`""" |
625 """ | |
626 if not isinstance(tree, tuple) or tree[0] in ( | 625 if not isinstance(tree, tuple) or tree[0] in ( |
627 b'string', | 626 b'string', |
628 b'symbol', | 627 b'symbol', |
629 b'smartset', | 628 b'smartset', |
630 ): | 629 ): |
740 b'p': _formatparamexp, | 739 b'p': _formatparamexp, |
741 } | 740 } |
742 | 741 |
743 | 742 |
744 def formatspec(expr, *args): | 743 def formatspec(expr, *args): |
745 ''' | 744 """ |
746 This is a convenience function for using revsets internally, and | 745 This is a convenience function for using revsets internally, and |
747 escapes arguments appropriately. Aliases are intentionally ignored | 746 escapes arguments appropriately. Aliases are intentionally ignored |
748 so that intended expression behavior isn't accidentally subverted. | 747 so that intended expression behavior isn't accidentally subverted. |
749 | 748 |
750 Supported arguments: | 749 Supported arguments: |
775 "root(_list('a\\\\x00b\\\\x00c\\\\x00d'))" | 774 "root(_list('a\\\\x00b\\\\x00c\\\\x00d'))" |
776 >>> formatspec(b'sort(%r, %ps)', b':', [b'desc', b'user']) | 775 >>> formatspec(b'sort(%r, %ps)', b':', [b'desc', b'user']) |
777 "sort((:), 'desc', 'user')" | 776 "sort((:), 'desc', 'user')" |
778 >>> formatspec(b'%ls', [b'a', b"'"]) | 777 >>> formatspec(b'%ls', [b'a', b"'"]) |
779 "_list('a\\\\x00\\\\'')" | 778 "_list('a\\\\x00\\\\'')" |
780 ''' | 779 """ |
781 parsed = _parseargs(expr, args) | 780 parsed = _parseargs(expr, args) |
782 ret = [] | 781 ret = [] |
783 for t, arg in parsed: | 782 for t, arg in parsed: |
784 if t is None: | 783 if t is None: |
785 ret.append(arg) | 784 ret.append(arg) |