Chromium Code Reviews| Index: gclient.py |
| diff --git a/gclient.py b/gclient.py |
| index 48ac3a7f01002c98d4554801e8b8b78614c66818..812d071a0c1c024ab1ae6a3f0fce5e06c89e01d1 100644 |
| --- a/gclient.py |
| +++ b/gclient.py |
| @@ -644,20 +644,26 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): |
| if options.prepend_dir: |
|
M-A Ruel
2012/11/28 01:43:11
if options.prepend_dir and scm == 'git':
Isaac (away)
2012/11/28 02:02:36
Done.
|
| print_stdout = False |
| def filter_fn(line): |
|
M-A Ruel
2012/11/28 01:43:11
Add docstring along the lines
"""Git-specific path
Isaac (away)
2012/11/28 02:02:36
Done.
|
| + def mod_path(git_pathspec): |
| + match = re.match('(\S+?:)?([^\0]+)$', git_pathspec) |
|
M-A Ruel
2012/11/28 01:43:11
r
Isaac (away)
2012/11/28 02:02:36
Can't use r for these, because I am looking for a
|
| + modified_path = os.path.join(self.name, match.group(2)) |
| + branch = match.group(1) or '' |
|
M-A Ruel
2012/11/28 01:43:11
When r'(\S+?:)?' doesn't match, match.group(1) is
Isaac (away)
2012/11/28 02:02:36
Yep
|
| + return '%s%s' % (branch, modified_path) |
| + |
| + match = re.match('Binary file ([^\0]+) matches$', line) |
|
M-A Ruel
2012/11/28 01:43:11
r'^ ...
Isaac (away)
2012/11/28 02:02:36
ditto on the r. The ^ isn't necessary because of
|
| + if match: |
| + print 'Binary file %s matches' % mod_path(match.group(1)) |
| + return |
| + |
| items = line.split('\0') |
| - if len(items) == 1: |
| - match = re.match('Binary file (.*) matches$', line) |
| - if match: |
| - print 'Binary file %s matches' % os.path.join( |
| - self.name, match.group(1)) |
| - else: |
| - print line |
| - elif len(items) == 2 and items[1]: |
| - print '%s : %s' % (os.path.join(self.name, items[0]), items[1]) |
| - else: |
| + if len(items) == 2 and items[1]: |
| + print '%s : %s' % (mod_path(items[0]), items[1]) |
|
M-A Ruel
2012/11/28 01:43:11
normal git-grep output doesn't have a whitespace b
Isaac (away)
2012/11/28 02:02:36
Adding a space lets you double click and highlight
|
| + elif len(items) >= 2: |
| # Multiple null bytes or a single trailing null byte indicate |
| # git is likely displaying filenames only (such as with -l) |
| - print '\n'.join(os.path.join(self.name, f) for f in items if f) |
| + print '\n'.join([mod_path(path) for path in items if path]) |
|
M-A Ruel
2012/11/28 01:43:11
Please don't convert the generator into a list bef
Isaac (away)
2012/11/28 02:02:36
Nice! I always forget about these.
|
| + else: |
| + print line |
| else: |
| print_stdout = True |
| filter_fn = None |