Code review comment for lp:~parthm/bzr/503670-vila-grep-as-builtin

Revision history for this message
Parth Malwankar (parthm) wrote :

Bug #503670

This patch ports the Vincent's grep plugin https://code.launchpad.net/~vila/bzr/grep
to builtins. The grep command is now available as 'bzr grep PATTERN [-- options]'. All grep options are support (followed by '--').
The current implementation requires xargs and grep commands to be available.

This command uses an implementation of os.path.relpath (ported from python 2.6 as cmd_grep._relpath). I tried using osutils.relpath but I found the two to be
inconsistent with the python 2.6 version in argument ordering, having optional arg and handling of '.'. As I don't fully understand the use cases of osutils.relpath I decided to keep cmd_grep._relpath.

Note on windows usage.
I tried this on a windows system with http://unxutils.sourceforge.net/ installed.
The command silently existed for me even though xargs and grep are available. It may be a good idea to disable this command on non-POSIX OSes. We could add a new error type. Comments/suggestions?

Example usage:
[bzrlib]% ../bzr --no-plugins grep main_version -- -i
__init__.py: main_version = '%d.%d' % version_info[:2]
__init__.py: main_version = '%d.%d.%d' % version_info[:3]
__init__.py: return main_version
__init__.py: return main_version + sub_string
tests/blackbox/test_version.py: def test_main_version(self):
[bzrlib]%

« Back to merge proposal