##// END OF EJS Templates
revset: rename diff(pattern) to diffcontains(pattern)...
Yuya Nishihara -
r46342:c0059573 stable
parent child Browse files
Show More
@@ -994,24 +994,27 b' def destination(repo, subset, x):'
994 )
994 )
995
995
996
996
997 @predicate(b'diff(pattern)', weight=110)
997 @predicate(b'diffcontains(pattern)', weight=110)
998 def diff(repo, subset, x):
998 def diffcontains(repo, subset, x):
999 """Search revision differences for when the pattern was added or removed.
999 """Search revision differences for when the pattern was added or removed.
1000
1000
1001 The pattern may be a substring literal or a regular expression. See
1001 The pattern may be a substring literal or a regular expression. See
1002 :hg:`help revisions.patterns`.
1002 :hg:`help revisions.patterns`.
1003 """
1003 """
1004 args = getargsdict(x, b'diff', b'pattern')
1004 args = getargsdict(x, b'diffcontains', b'pattern')
1005 if b'pattern' not in args:
1005 if b'pattern' not in args:
1006 # i18n: "diff" is a keyword
1006 # i18n: "diffcontains" is a keyword
1007 raise error.ParseError(_(b'diff takes at least 1 argument'))
1007 raise error.ParseError(_(b'diffcontains takes at least 1 argument'))
1008
1008
1009 pattern = getstring(args[b'pattern'], _(b'diff requires a string pattern'))
1009 pattern = getstring(
1010 args[b'pattern'], _(b'diffcontains requires a string pattern')
1011 )
1010 regexp = stringutil.substringregexp(pattern, re.M)
1012 regexp = stringutil.substringregexp(pattern, re.M)
1011
1013
1012 # TODO: add support for file pattern and --follow. For example,
1014 # TODO: add support for file pattern and --follow. For example,
1013 # diff(pattern[, set]) where set may be file(pattern) or follow(pattern),
1015 # diffcontains(pattern[, set]) where set may be file(pattern) or
1014 # and we'll eventually add a support for narrowing files by revset?
1016 # follow(pattern), and we'll eventually add a support for narrowing
1017 # files by revset?
1015 fmatch = matchmod.always()
1018 fmatch = matchmod.always()
1016
1019
1017 def makefilematcher(ctx):
1020 def makefilematcher(ctx):
@@ -1030,7 +1033,7 b' def diff(repo, subset, x):'
1030 found = True
1033 found = True
1031 return found
1034 return found
1032
1035
1033 return subset.filter(testdiff, condrepr=(b'<diff %r>', pattern))
1036 return subset.filter(testdiff, condrepr=(b'<diffcontains %r>', pattern))
1034
1037
1035
1038
1036 @predicate(b'contentdivergent()', safe=True)
1039 @predicate(b'contentdivergent()', safe=True)
@@ -23,13 +23,13 b' pattern error'
23
23
24 invalid revset syntax
24 invalid revset syntax
25
25
26 $ hg log -r 'diff()'
26 $ hg log -r 'diffcontains()'
27 hg: parse error: diff takes at least 1 argument
27 hg: parse error: diffcontains takes at least 1 argument
28 [255]
28 [255]
29 $ hg log -r 'diff(:)'
29 $ hg log -r 'diffcontains(:)'
30 hg: parse error: diff requires a string pattern
30 hg: parse error: diffcontains requires a string pattern
31 [255]
31 [255]
32 $ hg log -r 'diff("re:**test**")'
32 $ hg log -r 'diffcontains("re:**test**")'
33 hg: parse error: invalid regular expression: nothing to repeat* (glob)
33 hg: parse error: invalid regular expression: nothing to repeat* (glob)
34 [255]
34 [255]
35
35
@@ -567,13 +567,13 b' Test wdir'
567
567
568 revset predicate for "grep --diff"
568 revset predicate for "grep --diff"
569
569
570 $ hg log -qr 'diff("re:^bl...$")'
570 $ hg log -qr 'diffcontains("re:^bl...$")'
571 0:203191eb5e21
571 0:203191eb5e21
572 $ hg log -qr 'diff("orange")'
572 $ hg log -qr 'diffcontains("orange")'
573 1:7c585a21e0d1
573 1:7c585a21e0d1
574 2:11bd8bc8d653
574 2:11bd8bc8d653
575 3:e0116d3829f8
575 3:e0116d3829f8
576 $ hg log -qr '2:0 & diff("orange")'
576 $ hg log -qr '2:0 & diffcontains("orange")'
577 2:11bd8bc8d653
577 2:11bd8bc8d653
578 1:7c585a21e0d1
578 1:7c585a21e0d1
579
579
General Comments 0
You need to be logged in to leave comments. Login now