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

Side by Side Diff: gclient.py

Issue 1611009: Provide a way to name a solution as part of the config command. (Closed) Base URL: svn://chrome-svn/chrome/trunk/tools/depot_tools/
Patch Set: Committed Created 10 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/gclient_test.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 """A wrapper script to manage a set of client modules in different SCM. 6 """A wrapper script to manage a set of client modules in different SCM.
7 7
8 This script is intended to be used to help basic management of client 8 This script is intended to be used to help basic management of client
9 program sources residing in one or more Subversion modules and Git 9 program sources residing in one or more Subversion modules and Git
10 repositories, along with other modules it depends on, also in Subversion or Git, 10 repositories, along with other modules it depends on, also in Subversion or Git,
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 usage: cleanup [options] [--] [svn cleanup args/options] 146 usage: cleanup [options] [--] [svn cleanup args/options]
147 147
148 Valid options: 148 Valid options:
149 --verbose : output additional diagnostics 149 --verbose : output additional diagnostics
150 """, 150 """,
151 "config": """Create a .gclient file in the current directory; this 151 "config": """Create a .gclient file in the current directory; this
152 specifies the configuration for further commands. After update/sync, 152 specifies the configuration for further commands. After update/sync,
153 top-level DEPS files in each module are read to determine dependent 153 top-level DEPS files in each module are read to determine dependent
154 modules to operate on as well. If optional [url] parameter is 154 modules to operate on as well. If optional [url] parameter is
155 provided, then configuration is read from a specified Subversion server 155 provided, then configuration is read from a specified Subversion server
156 URL. Otherwise, a --spec option must be provided. 156 URL. Otherwise, a --spec option must be provided. A --name option overrides
157 the default name for the solutions.
157 158
158 usage: config [option | url] [safesync url] 159 usage: config [option | url] [safesync url]
159 160
160 Valid options: 161 Valid options:
162 --name path : alternate relative path for the solution
161 --spec=GCLIENT_SPEC : contents of .gclient are read from string parameter. 163 --spec=GCLIENT_SPEC : contents of .gclient are read from string parameter.
162 *Note that due to Cygwin/Python brokenness, it 164 *Note that due to Cygwin/Python brokenness, it
163 probably can't contain any newlines.* 165 probably can't contain any newlines.*
164 166
165 Examples: 167 Examples:
166 gclient config https://gclient.googlecode.com/svn/trunk/gclient 168 gclient config https://gclient.googlecode.com/svn/trunk/gclient
167 configure a new client to check out gclient.py tool sources 169 configure a new client to check out gclient.py tool sources
170 gclient config --name tools https://gclient.googlecode.com/svn/trunk/gclient
168 gclient config --spec='solutions=[{"name":"gclient",""" 171 gclient config --spec='solutions=[{"name":"gclient","""
169 '"url":"https://gclient.googlecode.com/svn/trunk/gclient",' 172 '"url":"https://gclient.googlecode.com/svn/trunk/gclient",'
170 '"custom_deps":{}}]', 173 '"custom_deps":{}}]',
171 "diff": """Display the differences between two revisions of modules. 174 "diff": """Display the differences between two revisions of modules.
172 (Does 'svn diff' for each checked out module and dependences.) 175 (Does 'svn diff' for each checked out module and dependences.)
173 Additional args and options to 'svn diff' can be passed after 176 Additional args and options to 'svn diff' can be passed after
174 gclient options. 177 gclient options.
175 178
176 usage: diff [options] [--] [svn args/options] 179 usage: diff [options] [--] [svn args/options]
177 180
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 if len(args) < 1 and not options.spec: 955 if len(args) < 1 and not options.spec:
953 raise gclient_utils.Error("required argument missing; see 'gclient help " 956 raise gclient_utils.Error("required argument missing; see 'gclient help "
954 "config'") 957 "config'")
955 if os.path.exists(options.config_filename): 958 if os.path.exists(options.config_filename):
956 raise gclient_utils.Error("%s file already exists in the current directory" 959 raise gclient_utils.Error("%s file already exists in the current directory"
957 % options.config_filename) 960 % options.config_filename)
958 client = GClient('.', options) 961 client = GClient('.', options)
959 if options.spec: 962 if options.spec:
960 client.SetConfig(options.spec) 963 client.SetConfig(options.spec)
961 else: 964 else:
962 # TODO(darin): it would be nice to be able to specify an alternate relpath
963 # for the given URL.
964 base_url = args[0].rstrip('/') 965 base_url = args[0].rstrip('/')
965 name = base_url.split("/")[-1] 966 if not options.name:
967 name = base_url.split("/")[-1]
968 else:
969 # specify an alternate relpath for the given URL.
970 name = options.name
966 safesync_url = "" 971 safesync_url = ""
967 if len(args) > 1: 972 if len(args) > 1:
968 safesync_url = args[1] 973 safesync_url = args[1]
969 client.SetDefaultConfig(name, base_url, safesync_url) 974 client.SetDefaultConfig(name, base_url, safesync_url)
970 client.SaveConfig() 975 client.SaveConfig()
971 976
972 977
973 def DoExport(options, args): 978 def DoExport(options, args):
974 """Handle the export subcommand. 979 """Handle the export subcommand.
975 980
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 option_parser.add_option("", "--head", action="store_true", default=False, 1202 option_parser.add_option("", "--head", action="store_true", default=False,
1198 help=("skips any safesync_urls specified in " 1203 help=("skips any safesync_urls specified in "
1199 "configured solutions")) 1204 "configured solutions"))
1200 option_parser.add_option("", "--delete_unversioned_trees", 1205 option_parser.add_option("", "--delete_unversioned_trees",
1201 action="store_true", default=False, 1206 action="store_true", default=False,
1202 help=("on update, delete any unexpected " 1207 help=("on update, delete any unexpected "
1203 "unversioned trees that are in the checkout")) 1208 "unversioned trees that are in the checkout"))
1204 option_parser.add_option("", "--snapshot", action="store_true", default=False, 1209 option_parser.add_option("", "--snapshot", action="store_true", default=False,
1205 help=("(revinfo only), create a snapshot file " 1210 help=("(revinfo only), create a snapshot file "
1206 "of the current version of all repositories")) 1211 "of the current version of all repositories"))
1212 option_parser.add_option("", "--name",
1213 help="specify alternate relative solution path")
1207 option_parser.add_option("", "--gclientfile", default=None, 1214 option_parser.add_option("", "--gclientfile", default=None,
1208 metavar="FILENAME", 1215 metavar="FILENAME",
1209 help=("specify an alternate .gclient file")) 1216 help=("specify an alternate .gclient file"))
1210 1217
1211 if len(argv) < 2: 1218 if len(argv) < 2:
1212 # Users don't need to be told to use the 'help' command. 1219 # Users don't need to be told to use the 'help' command.
1213 option_parser.print_help() 1220 option_parser.print_help()
1214 return 1 1221 return 1
1215 # Add manual support for --version as first argument. 1222 # Add manual support for --version as first argument.
1216 if argv[1] == '--version': 1223 if argv[1] == '--version':
(...skipping 27 matching lines...) Expand all
1244 1251
1245 if "__main__" == __name__: 1252 if "__main__" == __name__:
1246 try: 1253 try:
1247 result = Main(sys.argv) 1254 result = Main(sys.argv)
1248 except gclient_utils.Error, e: 1255 except gclient_utils.Error, e:
1249 print >> sys.stderr, "Error: %s" % str(e) 1256 print >> sys.stderr, "Error: %s" % str(e)
1250 result = 1 1257 result = 1
1251 sys.exit(result) 1258 sys.exit(result)
1252 1259
1253 # vim: ts=2:sw=2:tw=80:et: 1260 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « no previous file | tests/gclient_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698