Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: gclient.py

Issue 11270056: Add gclient grep for git repos (Closed) Base URL: https://git.chromium.org/chromium/tools/depot_tools.git@master
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Meta checkout manager supporting both Subversion and GIT. 6 """Meta checkout manager supporting both Subversion and GIT.
7 7
8 Files 8 Files
9 .gclient : Current client configuration, written by 'config' command. 9 .gclient : Current client configuration, written by 'config' command.
10 Format is a Python script defining 'solutions', a list whose 10 Format is a Python script defining 'solutions', a list whose
(...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 return client.RunOnDeps('recurse', args) 1254 return client.RunOnDeps('recurse', args)
1255 1255
1256 1256
1257 @attr('usage', '[args ...]') 1257 @attr('usage', '[args ...]')
1258 def CMDfetch(parser, args): 1258 def CMDfetch(parser, args):
1259 """Fetches upstream commits for all modules. 1259 """Fetches upstream commits for all modules.
1260 1260
1261 Completely git-specific. Simply runs 'git fetch [args ...]' for each module. 1261 Completely git-specific. Simply runs 'git fetch [args ...]' for each module.
1262 """ 1262 """
1263 (options, args) = parser.parse_args(args) 1263 (options, args) = parser.parse_args(args)
1264 args = ['-j%d' % options.jobs, '-s', 'git', 'git', 'fetch'] + args 1264 return CMDrecurse(Parser(), [
1265 return CMDrecurse(parser, args) 1265 '--jobs=%d' % options.jobs, '--scm=git', 'git', 'fetch'] + args)
1266
1267
1268 def CMDgrep(parser, args):
1269 """Greps through git repos managed by gclient.
1270
1271 Runs 'git grep [args...]' for each module.
1272 """
1273 if not args:
1274 print 'Usage [-j <N>] git-grep args...'
M-A Ruel 2012/11/05 17:39:05 print >> sys.stderr, 'Usage: git cl grep [-j <N>]
Isaac (away) 2012/11/07 07:13:53 Done.
1275 return 1
1276
1277 # We can't use optparse because it will try to parse arguments sent
M-A Ruel 2012/11/05 13:51:14 You can, you need to use parser.disable_interspers
Isaac (away) 2012/11/05 17:09:53 That does not allow users to pass arguments to git
M-A Ruel 2012/11/05 17:39:05 Ok, I always used -- naturally but I agree it's us
Isaac (away) 2012/11/07 07:13:53 SG. Some git commands also use -- so prefer not t
1278 # to git grep and throw an error. :-(
1279 if re.match(r'-j\d+|--jobs=\d+', args[0]):
1280 jobs_arg, args = args[:1], args[1:]
1281 elif re.match(r'-j|--jobs', args[0]):
1282 jobs_arg, args = args[:2], args[2:]
1283 else:
1284 jobs_arg = ['--jobs=1']
1285
M-A Ruel 2012/11/05 17:39:05 You also lose support for -h and --help. But it's
Isaac (away) 2012/11/07 07:13:53 I fixed this w/ a regex -- see new review.
1286 return CMDrecurse(
1287 parser,
1288 jobs_arg + ['--ignore', '--scm=git', 'git', 'grep', '--color=Always']
1289 + args)
1266 1290
1267 1291
1268 @attr('usage', '[url] [safesync url]') 1292 @attr('usage', '[url] [safesync url]')
1269 def CMDconfig(parser, args): 1293 def CMDconfig(parser, args):
1270 """Create a .gclient file in the current directory. 1294 """Create a .gclient file in the current directory.
1271 1295
1272 This specifies the configuration for further commands. After update/sync, 1296 This specifies the configuration for further commands. After update/sync,
1273 top-level DEPS files in each module are read to determine dependent 1297 top-level DEPS files in each module are read to determine dependent
1274 modules to operate on as well. If optional [url] parameter is 1298 modules to operate on as well. If optional [url] parameter is
1275 provided, then configuration is read from a specified Subversion server 1299 provided, then configuration is read from a specified Subversion server
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
1673 except (gclient_utils.Error, subprocess2.CalledProcessError), e: 1697 except (gclient_utils.Error, subprocess2.CalledProcessError), e:
1674 print >> sys.stderr, 'Error: %s' % str(e) 1698 print >> sys.stderr, 'Error: %s' % str(e)
1675 return 1 1699 return 1
1676 1700
1677 1701
1678 if '__main__' == __name__: 1702 if '__main__' == __name__:
1679 fix_encoding.fix_encoding() 1703 fix_encoding.fix_encoding()
1680 sys.exit(Main(sys.argv[1:])) 1704 sys.exit(Main(sys.argv[1:]))
1681 1705
1682 # vim: ts=2:sw=2:tw=80:et: 1706 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698