equal
deleted
inserted
replaced
29 scmutil, |
29 scmutil, |
30 smartset, |
30 smartset, |
31 stack, |
31 stack, |
32 util, |
32 util, |
33 ) |
33 ) |
34 from .utils import dateutil |
34 from .utils import ( |
|
35 dateutil, |
|
36 stringutil, |
|
37 ) |
35 |
38 |
36 # helpers for processing parsed tree |
39 # helpers for processing parsed tree |
37 getsymbol = revsetlang.getsymbol |
40 getsymbol = revsetlang.getsymbol |
38 getstring = revsetlang.getstring |
41 getstring = revsetlang.getstring |
39 getinteger = revsetlang.getinteger |
42 getinteger = revsetlang.getinteger |
445 args = getargs(x, 0, 1, _('bookmark takes one or no arguments')) |
448 args = getargs(x, 0, 1, _('bookmark takes one or no arguments')) |
446 if args: |
449 if args: |
447 bm = getstring(args[0], |
450 bm = getstring(args[0], |
448 # i18n: "bookmark" is a keyword |
451 # i18n: "bookmark" is a keyword |
449 _('the argument to bookmark must be a string')) |
452 _('the argument to bookmark must be a string')) |
450 kind, pattern, matcher = util.stringmatcher(bm) |
453 kind, pattern, matcher = stringutil.stringmatcher(bm) |
451 bms = set() |
454 bms = set() |
452 if kind == 'literal': |
455 if kind == 'literal': |
453 bmrev = repo._bookmarks.get(pattern, None) |
456 bmrev = repo._bookmarks.get(pattern, None) |
454 if not bmrev: |
457 if not bmrev: |
455 raise error.RepoLookupError(_("bookmark '%s' does not exist") |
458 raise error.RepoLookupError(_("bookmark '%s' does not exist") |
490 b = getstring(x, '') |
493 b = getstring(x, '') |
491 except error.ParseError: |
494 except error.ParseError: |
492 # not a string, but another revspec, e.g. tip() |
495 # not a string, but another revspec, e.g. tip() |
493 pass |
496 pass |
494 else: |
497 else: |
495 kind, pattern, matcher = util.stringmatcher(b) |
498 kind, pattern, matcher = stringutil.stringmatcher(b) |
496 if kind == 'literal': |
499 if kind == 'literal': |
497 # note: falls through to the revspec case if no branch with |
500 # note: falls through to the revspec case if no branch with |
498 # this name exists and pattern kind is not specified explicitly |
501 # this name exists and pattern kind is not specified explicitly |
499 if pattern in repo.branchmap(): |
502 if pattern in repo.branchmap(): |
500 return subset.filter(lambda r: matcher(getbranch(r)), |
503 return subset.filter(lambda r: matcher(getbranch(r)), |
817 |
820 |
818 if 'value' in args: |
821 if 'value' in args: |
819 # i18n: "extra" is a keyword |
822 # i18n: "extra" is a keyword |
820 value = getstring(args['value'], _('second argument to extra must be ' |
823 value = getstring(args['value'], _('second argument to extra must be ' |
821 'a string')) |
824 'a string')) |
822 kind, value, matcher = util.stringmatcher(value) |
825 kind, value, matcher = stringutil.stringmatcher(value) |
823 |
826 |
824 def _matchvalue(r): |
827 def _matchvalue(r): |
825 extra = repo[r].extra() |
828 extra = repo[r].extra() |
826 return label in extra and (value is None or matcher(extra[label])) |
829 return label in extra and (value is None or matcher(extra[label])) |
827 |
830 |
1012 try: |
1015 try: |
1013 # i18n: "grep" is a keyword |
1016 # i18n: "grep" is a keyword |
1014 gr = re.compile(getstring(x, _("grep requires a string"))) |
1017 gr = re.compile(getstring(x, _("grep requires a string"))) |
1015 except re.error as e: |
1018 except re.error as e: |
1016 raise error.ParseError( |
1019 raise error.ParseError( |
1017 _('invalid match pattern: %s') % util.forcebytestr(e)) |
1020 _('invalid match pattern: %s') % stringutil.forcebytestr(e)) |
1018 |
1021 |
1019 def matches(x): |
1022 def matches(x): |
1020 c = repo[x] |
1023 c = repo[x] |
1021 for e in c.files() + [c.user(), c.description()]: |
1024 for e in c.files() + [c.user(), c.description()]: |
1022 if gr.search(e): |
1025 if gr.search(e): |
1284 args = getargs(x, 1, 1, _('named requires a namespace argument')) |
1287 args = getargs(x, 1, 1, _('named requires a namespace argument')) |
1285 |
1288 |
1286 ns = getstring(args[0], |
1289 ns = getstring(args[0], |
1287 # i18n: "named" is a keyword |
1290 # i18n: "named" is a keyword |
1288 _('the argument to named must be a string')) |
1291 _('the argument to named must be a string')) |
1289 kind, pattern, matcher = util.stringmatcher(ns) |
1292 kind, pattern, matcher = stringutil.stringmatcher(ns) |
1290 namespaces = set() |
1293 namespaces = set() |
1291 if kind == 'literal': |
1294 if kind == 'literal': |
1292 if pattern not in repo.names: |
1295 if pattern not in repo.names: |
1293 raise error.RepoLookupError(_("namespace '%s' does not exist") |
1296 raise error.RepoLookupError(_("namespace '%s' does not exist") |
1294 % ns) |
1297 % ns) |
1940 pat = getstring(args[0], _("subrepo requires a pattern")) |
1943 pat = getstring(args[0], _("subrepo requires a pattern")) |
1941 |
1944 |
1942 m = matchmod.exact(repo.root, repo.root, ['.hgsubstate']) |
1945 m = matchmod.exact(repo.root, repo.root, ['.hgsubstate']) |
1943 |
1946 |
1944 def submatches(names): |
1947 def submatches(names): |
1945 k, p, m = util.stringmatcher(pat) |
1948 k, p, m = stringutil.stringmatcher(pat) |
1946 for name in names: |
1949 for name in names: |
1947 if m(name): |
1950 if m(name): |
1948 yield name |
1951 yield name |
1949 |
1952 |
1950 def matches(x): |
1953 def matches(x): |
1993 f = lambda nodes: obsutil.allsuccessors(repo.obsstore, nodes) |
1996 f = lambda nodes: obsutil.allsuccessors(repo.obsstore, nodes) |
1994 d = _mapbynodefunc(repo, s, f) |
1997 d = _mapbynodefunc(repo, s, f) |
1995 return subset & d |
1998 return subset & d |
1996 |
1999 |
1997 def _substringmatcher(pattern, casesensitive=True): |
2000 def _substringmatcher(pattern, casesensitive=True): |
1998 kind, pattern, matcher = util.stringmatcher(pattern, |
2001 kind, pattern, matcher = stringutil.stringmatcher( |
1999 casesensitive=casesensitive) |
2002 pattern, casesensitive=casesensitive) |
2000 if kind == 'literal': |
2003 if kind == 'literal': |
2001 if not casesensitive: |
2004 if not casesensitive: |
2002 pattern = encoding.lower(pattern) |
2005 pattern = encoding.lower(pattern) |
2003 matcher = lambda s: pattern in encoding.lower(s) |
2006 matcher = lambda s: pattern in encoding.lower(s) |
2004 else: |
2007 else: |
2017 cl = repo.changelog |
2020 cl = repo.changelog |
2018 if args: |
2021 if args: |
2019 pattern = getstring(args[0], |
2022 pattern = getstring(args[0], |
2020 # i18n: "tag" is a keyword |
2023 # i18n: "tag" is a keyword |
2021 _('the argument to tag must be a string')) |
2024 _('the argument to tag must be a string')) |
2022 kind, pattern, matcher = util.stringmatcher(pattern) |
2025 kind, pattern, matcher = stringutil.stringmatcher(pattern) |
2023 if kind == 'literal': |
2026 if kind == 'literal': |
2024 # avoid resolving all tags |
2027 # avoid resolving all tags |
2025 tn = repo._tagscache.tags.get(pattern, None) |
2028 tn = repo._tagscache.tags.get(pattern, None) |
2026 if tn is None: |
2029 if tn is None: |
2027 raise error.RepoLookupError(_("tag '%s' does not exist") |
2030 raise error.RepoLookupError(_("tag '%s' does not exist") |