991 dests.__contains__, |
992 dests.__contains__, |
992 condrepr=lambda: b'<destination %r>' % _sortedb(dests), |
993 condrepr=lambda: b'<destination %r>' % _sortedb(dests), |
993 ) |
994 ) |
994 |
995 |
995 |
996 |
|
997 @predicate(b'diff(pattern)', weight=110) |
|
998 def diff(repo, subset, x): |
|
999 """Search revision differences for when the pattern was added or removed. |
|
1000 |
|
1001 The pattern may be a substring literal or a regular expression. See |
|
1002 :hg:`help revisions.patterns`. |
|
1003 """ |
|
1004 args = getargsdict(x, b'diff', b'pattern') |
|
1005 if b'pattern' not in args: |
|
1006 # i18n: "diff" is a keyword |
|
1007 raise error.ParseError(_(b'diff takes at least 1 argument')) |
|
1008 |
|
1009 pattern = getstring(args[b'pattern'], _(b'diff requires a string pattern')) |
|
1010 regexp = stringutil.substringregexp(pattern, re.M) |
|
1011 |
|
1012 # TODO: add support for file pattern and --follow. For example, |
|
1013 # diff(pattern[, set]) where set may be file(pattern) or follow(pattern), |
|
1014 # and we'll eventually add a support for narrowing files by revset? |
|
1015 fmatch = matchmod.always() |
|
1016 |
|
1017 def makefilematcher(ctx): |
|
1018 return fmatch |
|
1019 |
|
1020 # TODO: search in a windowed way |
|
1021 searcher = grepmod.grepsearcher(repo.ui, repo, regexp, diff=True) |
|
1022 |
|
1023 def testdiff(rev): |
|
1024 # consume the generator to discard revfiles/matches cache |
|
1025 found = False |
|
1026 for fn, ctx, pstates, states in searcher.searchfiles( |
|
1027 baseset([rev]), makefilematcher |
|
1028 ): |
|
1029 if next(grepmod.difflinestates(pstates, states), None): |
|
1030 found = True |
|
1031 return found |
|
1032 |
|
1033 return subset.filter(testdiff, condrepr=(b'<diff %r>', pattern)) |
|
1034 |
|
1035 |
996 @predicate(b'contentdivergent()', safe=True) |
1036 @predicate(b'contentdivergent()', safe=True) |
997 def contentdivergent(repo, subset, x): |
1037 def contentdivergent(repo, subset, x): |
998 """ |
1038 """ |
999 Final successors of changesets with an alternative set of final |
1039 Final successors of changesets with an alternative set of final |
1000 successors. (EXPERIMENTAL) |
1040 successors. (EXPERIMENTAL) |