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

Side by Side Diff: roll_dep_svn.py

Issue 1147033003: Rename roll-dep to roll-dep-svn and add roll-dep for git. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: improved Created 5 years, 7 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
« roll_dep.py ('K') | « roll_dep.py ('k') | 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) 2014 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2014 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 """This scripts takes the path to a dep and a git or svn revision, and updates 6 """Rolls a git-svn dependency.
7 the parent repo's DEPS file with the corresponding git revision. Sample
8 invocation:
9 7
10 [chromium/src]$ roll-dep third_party/WebKit 12345 8 It takes the path to a dep and a git commit hash or svn revision, and updates
9 the parent repo's DEPS file with the corresponding git commit hash.
10
11 Sample invocation:
12
13 [chromium/src]$ roll-dep-svn third_party/WebKit 12345
11 14
12 After the script completes, the DEPS file will be dirty with the new revision. 15 After the script completes, the DEPS file will be dirty with the new revision.
13 The user can then: 16 The user can then:
14 17
15 $ git add DEPS 18 $ git add DEPS
16 $ git commit 19 $ git commit
17 """ 20 """
18 21
19 import ast 22 import ast
20 import optparse 23 import optparse
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 deps_file_dir = os.path.normpath(os.path.dirname(deps_file)) 356 deps_file_dir = os.path.normpath(os.path.dirname(deps_file))
354 deps_file_root = Popen( 357 deps_file_root = Popen(
355 ['git', 'rev-parse', '--show-toplevel'], 358 ['git', 'rev-parse', '--show-toplevel'],
356 cwd=deps_file_dir, stdout=PIPE).communicate()[0].strip() 359 cwd=deps_file_dir, stdout=PIPE).communicate()[0].strip()
357 with open(os.path.join(deps_file_root, '.git', 'MERGE_MSG'), 'w') as fh: 360 with open(os.path.join(deps_file_root, '.git', 'MERGE_MSG'), 'w') as fh:
358 fh.write(commit_msg) 361 fh.write(commit_msg)
359 return 0 362 return 0
360 363
361 364
362 def main(argv): 365 def main(argv):
363 usage = 'Usage: roll_dep.py [options] <dep path> <rev> [ <DEPS file> ]' 366 usage = 'Usage: roll-dep-svn [options] <dep path> <rev> [ <DEPS file> ]'
364 parser = optparse.OptionParser(usage=usage, description=__doc__) 367 parser = optparse.OptionParser(usage=usage, description=__doc__)
365 parser.add_option('--no-verify-revision', 368 parser.add_option('--no-verify-revision',
366 help='Don\'t verify the revision passed in. This ' 369 help='Don\'t verify the revision passed in. This '
367 'also skips adding an svn revision comment ' 370 'also skips adding an svn revision comment '
368 'for git dependencies and requires the passed ' 371 'for git dependencies and requires the passed '
369 'revision to be a git hash.', 372 'revision to be a git hash.',
370 default=False, action='store_true') 373 default=False, action='store_true')
371 options, args = parser.parse_args(argv) 374 options, args = parser.parse_args(argv)
372 if len(args) not in (2, 3): 375 if len(args) not in (2, 3):
373 parser.error('Expected either 2 or 3 positional parameters.') 376 parser.error('Expected either 2 or 3 positional parameters.')
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 return 1 408 return 1
406 return update_deps(deps_file, dep_path, dep_name, git_rev, comment) 409 return update_deps(deps_file, dep_path, dep_name, git_rev, comment)
407 410
408 411
409 if __name__ == '__main__': 412 if __name__ == '__main__':
410 try: 413 try:
411 sys.exit(main(sys.argv[1:])) 414 sys.exit(main(sys.argv[1:]))
412 except KeyboardInterrupt: 415 except KeyboardInterrupt:
413 sys.stderr.write('interrupted\n') 416 sys.stderr.write('interrupted\n')
414 sys.exit(1) 417 sys.exit(1)
OLDNEW
« roll_dep.py ('K') | « roll_dep.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698