Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHG04e50037d957: revset: use {force,}bytestr to fix some %r formatting issues
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/revset.py (6 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Abandoned | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Abandoned | durin42 |
"""Like ``keyword(string)`` but accepts a regex. Use ``grep(r'...')`` | """Like ``keyword(string)`` but accepts a regex. Use ``grep(r'...')`` | ||||
to ensure special escape characters are handled correctly. Unlike | to ensure special escape characters are handled correctly. Unlike | ||||
``keyword(string)``, the match is case-sensitive. | ``keyword(string)``, the match is case-sensitive. | ||||
""" | """ | ||||
try: | try: | ||||
# i18n: "grep" is a keyword | # i18n: "grep" is a keyword | ||||
gr = re.compile(getstring(x, _("grep requires a string"))) | gr = re.compile(getstring(x, _("grep requires a string"))) | ||||
except re.error as e: | except re.error as e: | ||||
raise error.ParseError(_('invalid match pattern: %s') % e) | raise error.ParseError( | ||||
_('invalid match pattern: %s') % util.forcebytestr(e)) | |||||
def matches(x): | def matches(x): | ||||
c = repo[x] | c = repo[x] | ||||
for e in c.files() + [c.user(), c.description()]: | for e in c.files() + [c.user(), c.description()]: | ||||
if gr.search(e): | if gr.search(e): | ||||
return True | return True | ||||
return False | return False | ||||
keyflags = [] | keyflags = [] | ||||
for k in keys.split(): | for k in keys.split(): | ||||
fk = k | fk = k | ||||
reverse = (k.startswith('-')) | reverse = (k.startswith('-')) | ||||
if reverse: | if reverse: | ||||
k = k[1:] | k = k[1:] | ||||
if k not in _sortkeyfuncs and k != 'topo': | if k not in _sortkeyfuncs and k != 'topo': | ||||
raise error.ParseError(_("unknown sort key %r") % fk) | raise error.ParseError( | ||||
_("unknown sort key %r") % pycompat.bytestr(fk)) | |||||
keyflags.append((k, reverse)) | keyflags.append((k, reverse)) | ||||
if len(keyflags) > 1 and any(k == 'topo' for k, reverse in keyflags): | if len(keyflags) > 1 and any(k == 'topo' for k, reverse in keyflags): | ||||
# i18n: "topo" is a keyword | # i18n: "topo" is a keyword | ||||
raise error.ParseError(_('topo sort order cannot be combined ' | raise error.ParseError(_('topo sort order cannot be combined ' | ||||
'with other sort keys')) | 'with other sort keys')) | ||||
opts = {} | opts = {} |