Merge lp:~jelmer/brz/promote-grep into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/promote-grep
Merge into: lp:brz
Diff against target: 790 lines (+245/-394)
9 files modified
breezy/builtins.py (+178/-0)
breezy/grep.py (+46/-11)
breezy/plugins/grep/.bzrignore (+0/-1)
breezy/plugins/grep/NEWS (+0/-73)
breezy/plugins/grep/__init__.py (+0/-38)
breezy/plugins/grep/cmds.py (+0/-254)
breezy/tests/__init__.py (+1/-0)
breezy/tests/test_grep.py (+17/-17)
doc/en/release-notes/brz-3.0.txt (+3/-0)
To merge this branch: bzr merge lp:~jelmer/brz/promote-grep
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+359487@code.launchpad.net

Commit message

Move grep into core.

Description of the change

Move grep into core.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Thanks, I think is a good thing to do.

review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/builtins.py'
--- breezy/builtins.py 2019-01-27 18:48:32 +0000
+++ breezy/builtins.py 2019-02-04 01:01:36 +0000
@@ -6831,6 +6831,184 @@
6831 cmd_reconcile().run(".")6831 cmd_reconcile().run(".")
68326832
68336833
6834class cmd_grep(Command):
6835 """Print lines matching PATTERN for specified files and revisions.
6836
6837 This command searches the specified files and revisions for a given
6838 pattern. The pattern is specified as a Python regular expressions[1].
6839
6840 If the file name is not specified, the revisions starting with the
6841 current directory are searched recursively. If the revision number is
6842 not specified, the working copy is searched. To search the last committed
6843 revision, use the '-r -1' or '-r last:1' option.
6844
6845 Unversioned files are not searched unless explicitly specified on the
6846 command line. Unversioned directores are not searched.
6847
6848 When searching a pattern, the output is shown in the 'filepath:string'
6849 format. If a revision is explicitly searched, the output is shown as
6850 'filepath~N:string', where N is the revision number.
6851
6852 --include and --exclude options can be used to search only (or exclude
6853 from search) files with base name matches the specified Unix style GLOB
6854 pattern. The GLOB pattern an use *, ?, and [...] as wildcards, and \\
6855 to quote wildcard or backslash character literally. Note that the glob
6856 pattern is not a regular expression.
6857
6858 [1] http://docs.python.org/library/re.html#regular-expression-syntax
6859 """
6860
6861 encoding_type = 'replace'
6862 takes_args = ['pattern', 'path*']
6863 takes_options = [
6864 'verbose',
6865 'revision',
6866 Option('color', type=text_type, argname='when',
6867 help='Show match in color. WHEN is never, always or auto.'),
6868 Option('diff', short_name='p',
6869 help='Grep for pattern in changeset for each revision.'),
6870 ListOption('exclude', type=text_type, argname='glob', short_name='X',
6871 help="Skip files whose base name matches GLOB."),
6872 ListOption('include', type=text_type, argname='glob', short_name='I',
6873 help="Search only files whose base name matches GLOB."),
6874 Option('files-with-matches', short_name='l',
6875 help='Print only the name of each input file in '
6876 'which PATTERN is found.'),
6877 Option('files-without-match', short_name='L',
6878 help='Print only the name of each input file in '
6879 'which PATTERN is not found.'),
6880 Option('fixed-string', short_name='F',
6881 help='Interpret PATTERN is a single fixed string (not regex).'),
6882 Option('from-root',
6883 help='Search for pattern starting from the root of the branch. '
6884 '(implies --recursive)'),
6885 Option('ignore-case', short_name='i',
6886 help='Ignore case distinctions while matching.'),
6887 Option('levels',
6888 help='Number of levels to display - 0 for all, 1 for collapsed '
6889 '(1 is default).',
6890 argname='N',
6891 type=_parse_levels),
6892 Option('line-number', short_name='n',
6893 help='Show 1-based line number.'),
6894 Option('no-recursive',
6895 help="Don't recurse into subdirectories. (default is --recursive)"),
6896 Option('null', short_name='Z',
6897 help='Write an ASCII NUL (\\0) separator '
6898 'between output lines rather than a newline.'),
6899 ]
6900
6901 @display_command
6902 def run(self, verbose=False, ignore_case=False, no_recursive=False,
6903 from_root=False, null=False, levels=None, line_number=False,
6904 path_list=None, revision=None, pattern=None, include=None,
6905 exclude=None, fixed_string=False, files_with_matches=False,
6906 files_without_match=False, color=None, diff=False):
6907 from breezy import _termcolor
6908 from . import grep
6909 import re
6910 if path_list is None:
6911 path_list = ['.']
6912 else:
6913 if from_root:
6914 raise errors.BzrCommandError(
6915 'cannot specify both --from-root and PATH.')
6916
6917 if files_with_matches and files_without_match:
6918 raise errors.BzrCommandError(
6919 'cannot specify both '
6920 '-l/--files-with-matches and -L/--files-without-matches.')
6921
6922 global_config = _mod_config.GlobalConfig()
6923
6924 if color is None:
6925 color = global_config.get_user_option('grep_color')
6926
6927 if color is None:
6928 color = 'never'
6929
6930 if color not in ['always', 'never', 'auto']:
6931 raise errors.BzrCommandError('Valid values for --color are '
6932 '"always", "never" or "auto".')
6933
6934 if levels is None:
6935 levels = 1
6936
6937 print_revno = False
6938 if revision is not None or levels == 0:
6939 # print revision numbers as we may be showing multiple revisions
6940 print_revno = True
6941
6942 eol_marker = '\n'
6943 if null:
6944 eol_marker = '\0'
6945
6946 if not ignore_case and grep.is_fixed_string(pattern):
6947 # if the pattern isalnum, implicitly use to -F for faster grep
6948 fixed_string = True
6949 elif ignore_case and fixed_string:
6950 # GZ 2010-06-02: Fall back to regexp rather than lowercasing
6951 # pattern and text which will cause pain later
6952 fixed_string = False
6953 pattern = re.escape(pattern)
6954
6955 patternc = None
6956 re_flags = re.MULTILINE
6957 if ignore_case:
6958 re_flags |= re.IGNORECASE
6959
6960 if not fixed_string:
6961 patternc = grep.compile_pattern(
6962 pattern.encode(grep._user_encoding), re_flags)
6963
6964 if color == 'always':
6965 show_color = True
6966 elif color == 'never':
6967 show_color = False
6968 elif color == 'auto':
6969 show_color = _termcolor.allow_color()
6970
6971 opts = grep.GrepOptions()
6972
6973 opts.verbose = verbose
6974 opts.ignore_case = ignore_case
6975 opts.no_recursive = no_recursive
6976 opts.from_root = from_root
6977 opts.null = null
6978 opts.levels = levels
6979 opts.line_number = line_number
6980 opts.path_list = path_list
6981 opts.revision = revision
6982 opts.pattern = pattern
6983 opts.include = include
6984 opts.exclude = exclude
6985 opts.fixed_string = fixed_string
6986 opts.files_with_matches = files_with_matches
6987 opts.files_without_match = files_without_match
6988 opts.color = color
6989 opts.diff = False
6990
6991 opts.eol_marker = eol_marker
6992 opts.print_revno = print_revno
6993 opts.patternc = patternc
6994 opts.recursive = not no_recursive
6995 opts.fixed_string = fixed_string
6996 opts.outf = self.outf
6997 opts.show_color = show_color
6998
6999 if diff:
7000 # options not used:
7001 # files_with_matches, files_without_match
7002 # levels(?), line_number, from_root
7003 # include, exclude
7004 # These are silently ignored.
7005 grep.grep_diff(opts)
7006 elif revision is None:
7007 grep.workingtree_grep(opts)
7008 else:
7009 grep.versioned_grep(opts)
7010
7011
6834def _register_lazy_builtins():7012def _register_lazy_builtins():
6835 # register lazy builtins from other modules; called at startup and should7013 # register lazy builtins from other modules; called at startup and should
6836 # be only called once.7014 # be only called once.
68377015
=== renamed file 'breezy/plugins/grep/grep.py' => 'breezy/grep.py'
--- breezy/plugins/grep/grep.py 2018-11-21 03:20:30 +0000
+++ breezy/grep.py 2019-02-04 01:01:36 +0000
@@ -1,5 +1,5 @@
1# Copyright (C) 2010 Canonical Ltd1# Copyright (C) 2010 Canonical Ltd
2#2
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or5# the Free Software Foundation; either version 2 of the License, or
@@ -12,36 +12,35 @@
12#12#
13# You should have received a copy of the GNU General Public License13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA15# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1616
17from __future__ import absolute_import17from __future__ import absolute_import
1818
19import re19import re
2020
21from ...lazy_import import lazy_import21from .lazy_import import lazy_import
22lazy_import(globals(), """22lazy_import(globals(), """
23from fnmatch import fnmatch23from fnmatch import fnmatch
2424
25from breezy._termcolor import color_string, FG25from breezy._termcolor import color_string, FG
2626
27from breezy import (27from breezy import (
28 diff,
29 )
30""")
31from . import (
28 controldir,32 controldir,
29 diff,
30 errors,33 errors,
31 lazy_regex,34 osutils,
32 revision as _mod_revision,35 revision as _mod_revision,
33 )
34""")
35from breezy import (
36 osutils,
37 trace,36 trace,
38 )37 )
39from breezy.revisionspec import (38from .revisionspec import (
40 RevisionSpec,39 RevisionSpec,
41 RevisionSpec_revid,40 RevisionSpec_revid,
42 RevisionSpec_revno,41 RevisionSpec_revno,
43 )42 )
44from breezy.sixish import (43from .sixish import (
45 BytesIO,44 BytesIO,
46 )45 )
4746
@@ -52,6 +51,42 @@
52 """Raised when a revision is not on left-hand history."""51 """Raised when a revision is not on left-hand history."""
5352
5453
54class GrepOptions(object):
55 """Container to pass around grep options.
56
57 This class is used as a container to pass around user option and
58 some other params (like outf) to processing functions. This makes
59 it easier to add more options as grep evolves.
60 """
61 verbose = False
62 ignore_case = False
63 no_recursive = False
64 from_root = False
65 null = False
66 levels = None
67 line_number = False
68 path_list = None
69 revision = None
70 pattern = None
71 include = None
72 exclude = None
73 fixed_string = False
74 files_with_matches = False
75 files_without_match = False
76 color = None
77 diff = False
78
79 # derived options
80 recursive = None
81 eol_marker = None
82 patternc = None
83 sub_patternc = None
84 print_revno = None
85 fixed_string = None
86 outf = None
87 show_color = False
88
89
55def _rev_on_mainline(rev_tuple):90def _rev_on_mainline(rev_tuple):
56 """returns True is rev tuple is on mainline"""91 """returns True is rev tuple is on mainline"""
57 if len(rev_tuple) == 1:92 if len(rev_tuple) == 1:
5893
=== removed directory 'breezy/plugins/grep'
=== removed file 'breezy/plugins/grep/.bzrignore'
--- breezy/plugins/grep/.bzrignore 2010-06-08 03:05:42 +0000
+++ breezy/plugins/grep/.bzrignore 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1./build
20
=== removed file 'breezy/plugins/grep/NEWS'
--- breezy/plugins/grep/NEWS 2017-07-30 16:59:50 +0000
+++ breezy/plugins/grep/NEWS 1970-01-01 00:00:00 +0000
@@ -1,73 +0,0 @@
1This is the NEWS file from bzr-grep from before it was merged into bzr core.
2For changes before then, please refer to the main bzr log file.
3
4bzr-grep 0.5.0-final - Unreleased
5==================================
6* ``bzr grep`` now supports ``--diff|-p`` option to search through
7 changesets. (Parth Malwankar, #540705)
8
9* Option ``grep_color`` can be set in ``breezy.conf`` instead of using
10 the option ``--color`` from the command line. (Johan Dahlin)
11
12bzr-grep 0.4.0-final - 08-Jun-2010
13==================================
14* Add seperate output formatter to reduce duplication of search loops,
15 additionally make -Fi use regexp rather than lowercasing pattern and
16 entirety of text for the same reason. This also fixes bug #590589
17 - UnicodeDecodeError with options -Fi. (Martin [gz])
18
19* Added fast path for no match that avoids splitting the file text into
20 seperate lines and testing each one, by checking the entire text for a
21 possible match initially. (Martin [gz])
22
23* Added Makefile. (Parth Malwankar)
24
25* Fixed setup.py to work correctly. (Martin [gz])
26
27bzr-grep 0.3.0-final - 23-May-2010
28==================================
29* Support for --color option (POSIX only). (Parth Malwankar, #571694)
30
31* Revisions in branches without trees can now be searched with
32 -r option. (Parth Malwankar, #584240)
33
34* Trying to search working tree for a treeless branch no longer
35 produces a stack trace but gives an error message suggesting use of
36 -r option. (Parth Malwankar, #572658)
37
38bzr-grep 0.2.0-final - 30-Mar-2010
39==================================
40* 'binary file skipped' warning is not shows without --verbose flag
41 (Parth Malwankar, #539031)
42
43* Added support for -F/--fixed-string for faster search.
44 Simple patterns [a-zA-Z0-9 _] are now implicitly -F and searched faster.
45 (Parth Malwankar, #539263)
46
47* Better unicode handling. bzr-grep no longer crashes with UnicodeDecode
48 error for some outputs. (Parth Malwankar, #539258)
49
50* Faster grep for revision range. bzr-grep now caches results for
51 files that have not changed between revisions.
52 (Parth Malwankar, #542375)
53
54* Faster grep for specific revision. (Parth Malwankar, #539429)
55
56* Significant performance improvement. Working tree grep for bzr.dev
57 has gone from ~7.5s to ~1s. (Parth Malwankar, #539028)
58
59* Support for -L/--files-without-match and -l/files-with-matches
60 (Parth Malwankar, #540097)
61
62bzr-grep 0.1.0-final - 14-Mar-2010
63==================================
64* --recursive is now default. (Parth Malwankar, #536688)
65
66* ``bzr grep`` searches working copy by default. (Parth Malwankar, #537072)
67
68* --include/exclude=GLOB is now supported. (Parth Malwankar, #529889)
69
70bzr-grep 0.0.1-final - 10-Mar-2010
71==================================
72* Initial release (Parth Malwankar)
73
740
=== removed file 'breezy/plugins/grep/__init__.py'
--- breezy/plugins/grep/__init__.py 2018-11-11 04:08:32 +0000
+++ breezy/plugins/grep/__init__.py 1970-01-01 00:00:00 +0000
@@ -1,38 +0,0 @@
1# Copyright (C) 2010 Canonical Ltd
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
17"""Print lines matching PATTERN for specified files and revisions."""
18
19from __future__ import absolute_import
20
21from ... import version_info # noqa: F401
22from ...commands import plugin_cmds
23
24plugin_cmds.register_lazy("cmd_grep", [], "breezy.plugins.grep.cmds")
25
26
27def test_suite():
28 from ...tests import TestUtil
29
30 suite = TestUtil.TestSuite()
31 loader = TestUtil.TestLoader()
32 testmod_names = [
33 'test_grep',
34 ]
35
36 suite.addTest(loader.loadTestsFromModuleNames(
37 ["%s.%s" % (__name__, tmn) for tmn in testmod_names]))
38 return suite
390
=== removed file 'breezy/plugins/grep/cmds.py'
--- breezy/plugins/grep/cmds.py 2018-11-17 16:53:10 +0000
+++ breezy/plugins/grep/cmds.py 1970-01-01 00:00:00 +0000
@@ -1,254 +0,0 @@
1# Copyright (C) 2010 Canonical Ltd
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
17"""Print lines matching PATTERN for specified files and revisions."""
18
19from __future__ import absolute_import
20
21from ... import errors
22from ...commands import Command, display_command
23from ...option import Option, ListOption
24from ...config import GlobalConfig
25
26from ...sixish import (
27 text_type,
28 )
29
30# FIXME: _parse_levels should be shared with breezy.builtins. this is a copy
31# to avoid the error
32# "IllegalUseOfScopeReplacer: ScopeReplacer object '_parse_levels' was used
33# incorrectly: Object already cleaned up, did you assign it to another
34# variable?: _factory
35# with lazy import
36
37
38def _parse_levels(s):
39 try:
40 return int(s)
41 except ValueError:
42 msg = "The levels argument must be an integer."
43 raise errors.BzrCommandError(msg)
44
45
46class GrepOptions(object):
47 """Container to pass around grep options.
48
49 This class is used as a container to pass around user option and
50 some other params (like outf) to processing functions. This makes
51 it easier to add more options as grep evolves.
52 """
53 verbose = False
54 ignore_case = False
55 no_recursive = False
56 from_root = False
57 null = False
58 levels = None
59 line_number = False
60 path_list = None
61 revision = None
62 pattern = None
63 include = None
64 exclude = None
65 fixed_string = False
66 files_with_matches = False
67 files_without_match = False
68 color = None
69 diff = False
70
71 # derived options
72 recursive = None
73 eol_marker = None
74 patternc = None
75 sub_patternc = None
76 print_revno = None
77 fixed_string = None
78 outf = None
79 show_color = False
80
81
82class cmd_grep(Command):
83 """Print lines matching PATTERN for specified files and revisions.
84
85 This command searches the specified files and revisions for a given
86 pattern. The pattern is specified as a Python regular expressions[1].
87
88 If the file name is not specified, the revisions starting with the
89 current directory are searched recursively. If the revision number is
90 not specified, the working copy is searched. To search the last committed
91 revision, use the '-r -1' or '-r last:1' option.
92
93 Unversioned files are not searched unless explicitly specified on the
94 command line. Unversioned directores are not searched.
95
96 When searching a pattern, the output is shown in the 'filepath:string'
97 format. If a revision is explicitly searched, the output is shown as
98 'filepath~N:string', where N is the revision number.
99
100 --include and --exclude options can be used to search only (or exclude
101 from search) files with base name matches the specified Unix style GLOB
102 pattern. The GLOB pattern an use *, ?, and [...] as wildcards, and \\
103 to quote wildcard or backslash character literally. Note that the glob
104 pattern is not a regular expression.
105
106 [1] http://docs.python.org/library/re.html#regular-expression-syntax
107 """
108
109 encoding_type = 'replace'
110 takes_args = ['pattern', 'path*']
111 takes_options = [
112 'verbose',
113 'revision',
114 Option('color', type=text_type, argname='when',
115 help='Show match in color. WHEN is never, always or auto.'),
116 Option('diff', short_name='p',
117 help='Grep for pattern in changeset for each revision.'),
118 ListOption('exclude', type=text_type, argname='glob', short_name='X',
119 help="Skip files whose base name matches GLOB."),
120 ListOption('include', type=text_type, argname='glob', short_name='I',
121 help="Search only files whose base name matches GLOB."),
122 Option('files-with-matches', short_name='l',
123 help='Print only the name of each input file in '
124 'which PATTERN is found.'),
125 Option('files-without-match', short_name='L',
126 help='Print only the name of each input file in '
127 'which PATTERN is not found.'),
128 Option('fixed-string', short_name='F',
129 help='Interpret PATTERN is a single fixed string (not regex).'),
130 Option('from-root',
131 help='Search for pattern starting from the root of the branch. '
132 '(implies --recursive)'),
133 Option('ignore-case', short_name='i',
134 help='ignore case distinctions while matching.'),
135 Option('levels',
136 help='Number of levels to display - 0 for all, 1 for collapsed '
137 '(1 is default).',
138 argname='N',
139 type=_parse_levels),
140 Option('line-number', short_name='n',
141 help='show 1-based line number.'),
142 Option('no-recursive',
143 help="Don't recurse into subdirectories. (default is --recursive)"),
144 Option('null', short_name='Z',
145 help='Write an ASCII NUL (\\0) separator '
146 'between output lines rather than a newline.'),
147 ]
148
149 @display_command
150 def run(self, verbose=False, ignore_case=False, no_recursive=False,
151 from_root=False, null=False, levels=None, line_number=False,
152 path_list=None, revision=None, pattern=None, include=None,
153 exclude=None, fixed_string=False, files_with_matches=False,
154 files_without_match=False, color=None, diff=False):
155 from breezy import _termcolor
156 from . import grep
157 import re
158 if path_list is None:
159 path_list = ['.']
160 else:
161 if from_root:
162 raise errors.BzrCommandError(
163 'cannot specify both --from-root and PATH.')
164
165 if files_with_matches and files_without_match:
166 raise errors.BzrCommandError('cannot specify both '
167 '-l/--files-with-matches and -L/--files-without-matches.')
168
169 global_config = GlobalConfig()
170
171 if color is None:
172 color = global_config.get_user_option('grep_color')
173
174 if color is None:
175 color = 'never'
176
177 if color not in ['always', 'never', 'auto']:
178 raise errors.BzrCommandError('Valid values for --color are '
179 '"always", "never" or "auto".')
180
181 if levels is None:
182 levels = 1
183
184 print_revno = False
185 if revision is not None or levels == 0:
186 # print revision numbers as we may be showing multiple revisions
187 print_revno = True
188
189 eol_marker = '\n'
190 if null:
191 eol_marker = '\0'
192
193 if not ignore_case and grep.is_fixed_string(pattern):
194 # if the pattern isalnum, implicitly use to -F for faster grep
195 fixed_string = True
196 elif ignore_case and fixed_string:
197 # GZ 2010-06-02: Fall back to regexp rather than lowercasing
198 # pattern and text which will cause pain later
199 fixed_string = False
200 pattern = re.escape(pattern)
201
202 patternc = None
203 re_flags = re.MULTILINE
204 if ignore_case:
205 re_flags |= re.IGNORECASE
206
207 if not fixed_string:
208 patternc = grep.compile_pattern(
209 pattern.encode(grep._user_encoding), re_flags)
210
211 if color == 'always':
212 show_color = True
213 elif color == 'never':
214 show_color = False
215 elif color == 'auto':
216 show_color = _termcolor.allow_color()
217
218 GrepOptions.verbose = verbose
219 GrepOptions.ignore_case = ignore_case
220 GrepOptions.no_recursive = no_recursive
221 GrepOptions.from_root = from_root
222 GrepOptions.null = null
223 GrepOptions.levels = levels
224 GrepOptions.line_number = line_number
225 GrepOptions.path_list = path_list
226 GrepOptions.revision = revision
227 GrepOptions.pattern = pattern
228 GrepOptions.include = include
229 GrepOptions.exclude = exclude
230 GrepOptions.fixed_string = fixed_string
231 GrepOptions.files_with_matches = files_with_matches
232 GrepOptions.files_without_match = files_without_match
233 GrepOptions.color = color
234 GrepOptions.diff = False
235
236 GrepOptions.eol_marker = eol_marker
237 GrepOptions.print_revno = print_revno
238 GrepOptions.patternc = patternc
239 GrepOptions.recursive = not no_recursive
240 GrepOptions.fixed_string = fixed_string
241 GrepOptions.outf = self.outf
242 GrepOptions.show_color = show_color
243
244 if diff:
245 # options not used:
246 # files_with_matches, files_without_match
247 # levels(?), line_number, from_root
248 # include, exclude
249 # These are silently ignored.
250 grep.grep_diff(GrepOptions)
251 elif revision is None:
252 grep.workingtree_grep(GrepOptions)
253 else:
254 grep.versioned_grep(GrepOptions)
2550
=== modified file 'breezy/tests/__init__.py'
--- breezy/tests/__init__.py 2018-11-23 23:51:34 +0000
+++ breezy/tests/__init__.py 2019-02-04 01:01:36 +0000
@@ -4107,6 +4107,7 @@
4107 'breezy.tests.test_globbing',4107 'breezy.tests.test_globbing',
4108 'breezy.tests.test_gpg',4108 'breezy.tests.test_gpg',
4109 'breezy.tests.test_graph',4109 'breezy.tests.test_graph',
4110 'breezy.tests.test_grep',
4110 'breezy.tests.test_groupcompress',4111 'breezy.tests.test_groupcompress',
4111 'breezy.tests.test_hashcache',4112 'breezy.tests.test_hashcache',
4112 'breezy.tests.test_help',4113 'breezy.tests.test_help',
41134114
=== renamed file 'breezy/plugins/grep/test_grep.py' => 'breezy/tests/test_grep.py'
--- breezy/plugins/grep/test_grep.py 2018-11-12 01:41:38 +0000
+++ breezy/tests/test_grep.py 2019-02-04 01:01:36 +0000
@@ -12,7 +12,7 @@
12#12#
13# You should have received a copy of the GNU General Public License13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA15# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1616
17from __future__ import absolute_import17from __future__ import absolute_import
1818
@@ -20,11 +20,11 @@
20import re20import re
21import unicodedata as ud21import unicodedata as ud
2222
23from ... import tests, osutils23from .. import tests, osutils
24from ...sixish import PY324from ..sixish import PY3
25from ..._termcolor import color_string, FG25from .._termcolor import color_string, FG
2626
27from ...tests.features import (27from ..tests.features import (
28 UnicodeFilenameFeature,28 UnicodeFilenameFeature,
29 )29 )
3030
@@ -2429,13 +2429,13 @@
2429 self.assertEqualDiff(subst_dates(out), '''\2429 self.assertEqualDiff(subst_dates(out), '''\
2430=== revno:3 ===2430=== revno:3 ===
2431 === modified file 'hello'2431 === modified file 'hello'
2432 --- hello YYYY-MM-DD HH:MM:SS +ZZZZ2432 --- hello\tYYYY-MM-DD HH:MM:SS +ZZZZ
2433 +++ hello YYYY-MM-DD HH:MM:SS +ZZZZ2433 +++ hello\tYYYY-MM-DD HH:MM:SS +ZZZZ
2434 +hello world!2434 +hello world!
2435=== revno:1 ===2435=== revno:1 ===
2436 === added file 'hello'2436 === added file 'hello'
2437 --- hello YYYY-MM-DD HH:MM:SS +ZZZZ2437 --- hello\tYYYY-MM-DD HH:MM:SS +ZZZZ
2438 +++ hello YYYY-MM-DD HH:MM:SS +ZZZZ2438 +++ hello\tYYYY-MM-DD HH:MM:SS +ZZZZ
2439''')2439''')
24402440
2441 def test_grep_diff_revision(self):2441 def test_grep_diff_revision(self):
@@ -2448,8 +2448,8 @@
2448 self.assertEqualDiff(subst_dates(out), '''\2448 self.assertEqualDiff(subst_dates(out), '''\
2449=== revno:3 ===2449=== revno:3 ===
2450 === modified file 'hello'2450 === modified file 'hello'
2451 --- hello YYYY-MM-DD HH:MM:SS +ZZZZ2451 --- hello\tYYYY-MM-DD HH:MM:SS +ZZZZ
2452 +++ hello YYYY-MM-DD HH:MM:SS +ZZZZ2452 +++ hello\tYYYY-MM-DD HH:MM:SS +ZZZZ
2453 +hello world!2453 +hello world!
2454''')2454''')
24552455
@@ -2470,16 +2470,16 @@
2470 self.assertEqualDiff(subst_dates(out), '''\2470 self.assertEqualDiff(subst_dates(out), '''\
2471=== revno:5 ===2471=== revno:5 ===
2472 === modified file 'hello'2472 === modified file 'hello'
2473 --- hello YYYY-MM-DD HH:MM:SS +ZZZZ2473 --- hello\tYYYY-MM-DD HH:MM:SS +ZZZZ
2474 +++ hello YYYY-MM-DD HH:MM:SS +ZZZZ2474 +++ hello\tYYYY-MM-DD HH:MM:SS +ZZZZ
2475 +hello world!32475 +hello world!3
2476=== revno:4 ===2476=== revno:4 ===
2477 === added file 'blah'2477 === added file 'blah'
2478 +hello world!22478 +hello world!2
2479=== revno:3 ===2479=== revno:3 ===
2480 === modified file 'hello'2480 === modified file 'hello'
2481 --- hello YYYY-MM-DD HH:MM:SS +ZZZZ2481 --- hello\tYYYY-MM-DD HH:MM:SS +ZZZZ
2482 +++ hello YYYY-MM-DD HH:MM:SS +ZZZZ2482 +++ hello\tYYYY-MM-DD HH:MM:SS +ZZZZ
2483 +hello world!12483 +hello world!1
2484''')2484''')
24852485
@@ -2496,8 +2496,8 @@
2496 " === modified file 'hello'", fg=FG.BOLD_MAGENTA) + '\n'2496 " === modified file 'hello'", fg=FG.BOLD_MAGENTA) + '\n'
2497 redhello = color_string('hello', fg=FG.BOLD_RED)2497 redhello = color_string('hello', fg=FG.BOLD_RED)
2498 diffstr = '''\2498 diffstr = '''\
2499 --- hello YYYY-MM-DD HH:MM:SS +ZZZZ2499 --- hello\tYYYY-MM-DD HH:MM:SS +ZZZZ
2500 +++ hello YYYY-MM-DD HH:MM:SS +ZZZZ2500 +++ hello\tYYYY-MM-DD HH:MM:SS +ZZZZ
2501 +hello world!2501 +hello world!
2502'''2502'''
2503 diffstr = diffstr.replace('hello', redhello)2503 diffstr = diffstr.replace('hello', redhello)
25042504
=== modified file 'doc/en/release-notes/brz-3.0.txt'
--- doc/en/release-notes/brz-3.0.txt 2019-02-02 22:23:40 +0000
+++ doc/en/release-notes/brz-3.0.txt 2019-02-04 01:01:36 +0000
@@ -93,6 +93,9 @@
93 * The 'fastimport' plugin is now bundled with Breezy.93 * The 'fastimport' plugin is now bundled with Breezy.
94 (Jelmer Vernooij)94 (Jelmer Vernooij)
9595
96 * The ``grep`` plugin has been merged into Breezy.
97 (Parth Malwankar, Martin Packman, Jelmer Vernooij)
98
96 * The 'stats' plugin is now bundled with Breezy.99 * The 'stats' plugin is now bundled with Breezy.
97 (Jelmer Vernooij)100 (Jelmer Vernooij)
98101

Subscribers

People subscribed via source and target branches