1017 ``keyword(string)``, the match is case-sensitive. |
1017 ``keyword(string)``, the match is case-sensitive. |
1018 """ |
1018 """ |
1019 try: |
1019 try: |
1020 # i18n: "grep" is a keyword |
1020 # i18n: "grep" is a keyword |
1021 gr = re.compile(getstring(x, _("grep requires a string"))) |
1021 gr = re.compile(getstring(x, _("grep requires a string"))) |
1022 except re.error, e: |
1022 except re.error as e: |
1023 raise error.ParseError(_('invalid match pattern: %s') % e) |
1023 raise error.ParseError(_('invalid match pattern: %s') % e) |
1024 |
1024 |
1025 def matches(x): |
1025 def matches(x): |
1026 c = repo[x] |
1026 c = repo[x] |
1027 for e in c.files() + [c.user(), c.description()]: |
1027 for e in c.files() + [c.user(), c.description()]: |
1898 """ |
1898 """ |
1899 if pattern.startswith('re:'): |
1899 if pattern.startswith('re:'): |
1900 pattern = pattern[3:] |
1900 pattern = pattern[3:] |
1901 try: |
1901 try: |
1902 regex = re.compile(pattern) |
1902 regex = re.compile(pattern) |
1903 except re.error, e: |
1903 except re.error as e: |
1904 raise error.ParseError(_('invalid regular expression: %s') |
1904 raise error.ParseError(_('invalid regular expression: %s') |
1905 % e) |
1905 % e) |
1906 return 're', pattern, regex.search |
1906 return 're', pattern, regex.search |
1907 elif pattern.startswith('literal:'): |
1907 elif pattern.startswith('literal:'): |
1908 pattern = pattern[8:] |
1908 pattern = pattern[8:] |
2414 return (name, None, None, |
2414 return (name, None, None, |
2415 _("argument names collide with each other")) |
2415 _("argument names collide with each other")) |
2416 return (name, ('func', ('symbol', name)), args, None) |
2416 return (name, ('func', ('symbol', name)), args, None) |
2417 |
2417 |
2418 return (decl, None, None, _("invalid format")) |
2418 return (decl, None, None, _("invalid format")) |
2419 except error.ParseError, inst: |
2419 except error.ParseError as inst: |
2420 return (decl, None, None, parseerrordetail(inst)) |
2420 return (decl, None, None, parseerrordetail(inst)) |
2421 |
2421 |
2422 def _parsealiasdefn(defn, args): |
2422 def _parsealiasdefn(defn, args): |
2423 """Parse alias definition ``defn`` |
2423 """Parse alias definition ``defn`` |
2424 |
2424 |
2503 |
2503 |
2504 try: |
2504 try: |
2505 self.replacement = _parsealiasdefn(value, self.args) |
2505 self.replacement = _parsealiasdefn(value, self.args) |
2506 # Check for placeholder injection |
2506 # Check for placeholder injection |
2507 _checkaliasarg(self.replacement, self.args) |
2507 _checkaliasarg(self.replacement, self.args) |
2508 except error.ParseError, inst: |
2508 except error.ParseError as inst: |
2509 self.error = _('failed to parse the definition of revset alias' |
2509 self.error = _('failed to parse the definition of revset alias' |
2510 ' "%s": %s') % (self.name, parseerrordetail(inst)) |
2510 ' "%s": %s') % (self.name, parseerrordetail(inst)) |
2511 |
2511 |
2512 def _getalias(aliases, tree): |
2512 def _getalias(aliases, tree): |
2513 """If tree looks like an unexpanded alias, return it. Return None |
2513 """If tree looks like an unexpanded alias, return it. Return None |