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

Side by Side Diff: gclient.py

Issue 2862039: Add gclient recurse (Closed)
Patch Set: address review comments Created 10 years, 5 months 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 | tests/gclient_smoketest.py » ('j') | 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/python 1 #!/usr/bin/python
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2010 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 """ 50 """
51 51
52 __version__ = "0.4.1" 52 __version__ = "0.4.1"
53 53
54 import errno 54 import errno
55 import logging 55 import logging
56 import optparse 56 import optparse
57 import os 57 import os
58 import pprint 58 import pprint
59 import re 59 import re
60 import subprocess
60 import sys 61 import sys
61 import urlparse 62 import urlparse
62 import urllib 63 import urllib
63 64
64 import breakpad 65 import breakpad
65 66
66 import gclient_scm 67 import gclient_scm
67 import gclient_utils 68 import gclient_utils
68 from third_party.repo.progress import Progress 69 from third_party.repo.progress import Progress
69 70
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 client = GClient.LoadCurrentConfig(options) 850 client = GClient.LoadCurrentConfig(options)
850 if not client: 851 if not client:
851 raise gclient_utils.Error('client not configured; see \'gclient config\'') 852 raise gclient_utils.Error('client not configured; see \'gclient config\'')
852 if options.verbose: 853 if options.verbose:
853 # Print out the .gclient file. This is longer than if we just printed the 854 # Print out the .gclient file. This is longer than if we just printed the
854 # client dict, but more legible, and it might contain helpful comments. 855 # client dict, but more legible, and it might contain helpful comments.
855 print(client.config_content) 856 print(client.config_content)
856 return client.RunOnDeps('cleanup', args) 857 return client.RunOnDeps('cleanup', args)
857 858
858 859
860 @attr('usage', '[command] [args ...]')
861 def CMDrecurse(parser, args):
862 """Operates on all the entries.
863
864 Runs a shell command on all entries.
865 """
866 # Stop parsing at the first non-arg so that these go through to the command
867 parser.disable_interspersed_args()
868 parser.add_option('-s', '--scm', action='append', default=[],
869 help='choose scm types to operate upon')
870 options, args = parser.parse_args(args)
871 root, entries = gclient_utils.GetGClientRootAndEntries()
872 scm_set = set()
873 for scm in options.scm:
874 scm_set.update(scm.split(','))
875
876 # Pass in the SCM type as an env variable
877 env = os.environ.copy()
878
879 for path, url in entries.iteritems():
880 scm = gclient_scm.GetScmName(url)
881 if scm_set and scm not in scm_set:
882 continue
883 dir = os.path.normpath(os.path.join(root, path))
884 env['GCLIENT_SCM'] = scm
885 env['GCLIENT_URL'] = url
886 subprocess.Popen(args, cwd=dir, env=env).communicate()
887
888
859 @attr('usage', '[url] [safesync url]') 889 @attr('usage', '[url] [safesync url]')
860 def CMDconfig(parser, args): 890 def CMDconfig(parser, args):
861 """Create a .gclient file in the current directory. 891 """Create a .gclient file in the current directory.
862 892
863 This specifies the configuration for further commands. After update/sync, 893 This specifies the configuration for further commands. After update/sync,
864 top-level DEPS files in each module are read to determine dependent 894 top-level DEPS files in each module are read to determine dependent
865 modules to operate on as well. If optional [url] parameter is 895 modules to operate on as well. If optional [url] parameter is
866 provided, then configuration is read from a specified Subversion server 896 provided, then configuration is read from a specified Subversion server
867 URL. 897 URL.
868 """ 898 """
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 return CMDhelp(parser, argv) 1208 return CMDhelp(parser, argv)
1179 except gclient_utils.Error, e: 1209 except gclient_utils.Error, e:
1180 print >> sys.stderr, 'Error: %s' % str(e) 1210 print >> sys.stderr, 'Error: %s' % str(e)
1181 return 1 1211 return 1
1182 1212
1183 1213
1184 if '__main__' == __name__: 1214 if '__main__' == __name__:
1185 sys.exit(Main(sys.argv[1:])) 1215 sys.exit(Main(sys.argv[1:]))
1186 1216
1187 # vim: ts=2:sw=2:tw=80:et: 1217 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « no previous file | tests/gclient_smoketest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698