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

Side by Side Diff: roll_dep.py

Issue 513383002: Modify roll_dep's commit message (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 6 years, 3 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 | 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 an svn revision, and updates the 6 """This scripts takes the path to a dep and an svn revision, and updates the
7 parent repo's DEPS file with the corresponding git revision. Sample invocation: 7 parent repo's DEPS file with the corresponding git revision. Sample invocation:
8 8
9 [chromium/src]$ roll-dep third_party/WebKit 12345 9 [chromium/src]$ roll-dep third_party/WebKit 12345
10 10
11 After the script completes, the DEPS file will be dirty with the new revision. 11 After the script completes, the DEPS file will be dirty with the new revision.
12 The user can then: 12 The user can then:
13 13
14 $ git add DEPS 14 $ git add DEPS
15 $ git commit 15 $ git commit
16 """ 16 """
17 17
18 import ast 18 import ast
19 import os 19 import os
20 import re 20 import re
21 import sys 21 import sys
22 22
23 from itertools import izip 23 from itertools import izip
24 from subprocess import Popen, PIPE 24 from subprocess import Popen, PIPE
25 from textwrap import dedent 25 from textwrap import dedent
26 26
27 27
28 SHA1_RE = re.compile('^[a-fA-F0-9]{40}$') 28 SHA1_RE = re.compile('^[a-fA-F0-9]{40}$')
29 GIT_SVN_ID_RE = re.compile('^git-svn-id: .*@([0-9]+) .*$') 29 GIT_SVN_ID_RE = re.compile('^git-svn-id: .*@([0-9]+) .*$')
30 ROLL_DESCRIPTION_STR = '''Roll %s from %s to %s
31
32 Summary of changes available at: %s
szager1 2014/08/28 21:24:51 Let's move the link to another line, to hopefully
borenet 2014/08/29 13:32:02 Done.
33 '''
30 34
31 35
32 def posix_path(path): 36 def posix_path(path):
33 """Convert a possibly-Windows path to a posix-style path.""" 37 """Convert a possibly-Windows path to a posix-style path."""
34 (_, path) = os.path.splitdrive(path) 38 (_, path) = os.path.splitdrive(path)
35 return path.replace(os.sep, '/') 39 return path.replace(os.sep, '/')
36 40
37 41
38 def platform_path(path): 42 def platform_path(path):
39 """Convert a path to the native path format of the host OS.""" 43 """Convert a path to the native path format of the host OS."""
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 'Could not find definition of "%s" var in DEPS file.' % var_name) 245 'Could not find definition of "%s" var in DEPS file.' % var_name)
242 val_node = vars_node.values[var_idx] 246 val_node = vars_node.values[var_idx]
243 return update_node(deps_lines, deps_ast, val_node, git_revision) 247 return update_node(deps_lines, deps_ast, val_node, git_revision)
244 248
245 249
246 def generate_commit_message(deps_section, dep_name, new_rev): 250 def generate_commit_message(deps_section, dep_name, new_rev):
247 (url, _, old_rev) = deps_section[dep_name].partition('@') 251 (url, _, old_rev) = deps_section[dep_name].partition('@')
248 if url.endswith('.git'): 252 if url.endswith('.git'):
249 url = url[:-4] 253 url = url[:-4]
250 url += '/+log/%s..%s' % (old_rev[:12], new_rev[:12]) 254 url += '/+log/%s..%s' % (old_rev[:12], new_rev[:12])
251 return dedent('''\ 255 return dedent(ROLL_DESCRIPTION_STR % (
252 Rolled %s 256 dep_name, old_rev[:12], new_rev[:12], url))
szager1 2014/08/28 21:23:15 Can we use ellipses for over-long dep names? Some
borenet 2014/08/29 13:32:02 Done. Added a helper function since my intention
253 from revision %s
254 to revision %s
255 Summary of changes available at:
256 %s\n''' % (dep_name, old_rev, new_rev, url))
257 257
258 def update_deps_entry(deps_lines, deps_ast, value_node, new_rev, comment): 258 def update_deps_entry(deps_lines, deps_ast, value_node, new_rev, comment):
259 line_idx = update_node(deps_lines, deps_ast, value_node, new_rev) 259 line_idx = update_node(deps_lines, deps_ast, value_node, new_rev)
260 (content, _, _) = deps_lines[line_idx].partition('#') 260 (content, _, _) = deps_lines[line_idx].partition('#')
261 if comment: 261 if comment:
262 deps_lines[line_idx] = '%s # %s' % (content.rstrip(), comment) 262 deps_lines[line_idx] = '%s # %s' % (content.rstrip(), comment)
263 else: 263 else:
264 deps_lines[line_idx] = content.rstrip() 264 deps_lines[line_idx] = content.rstrip()
265 265
266 def update_deps(soln_path, dep_name, new_rev, comment): 266 def update_deps(soln_path, dep_name, new_rev, comment):
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 soln = get_solution(gclient_root, dep_path) 320 soln = get_solution(gclient_root, dep_path)
321 soln_path = os.path.relpath(os.path.join(gclient_root, soln['name'])) 321 soln_path = os.path.relpath(os.path.join(gclient_root, soln['name']))
322 dep_name = posix_path(os.path.relpath(dep_path, gclient_root)) 322 dep_name = posix_path(os.path.relpath(dep_path, gclient_root))
323 (git_rev, svn_rev) = get_git_revision(dep_path, revision) 323 (git_rev, svn_rev) = get_git_revision(dep_path, revision)
324 comment = ('from svn revision %s' % svn_rev) if svn_rev else None 324 comment = ('from svn revision %s' % svn_rev) if svn_rev else None
325 assert git_rev, 'Could not find git revision matching %s.' % revision 325 assert git_rev, 'Could not find git revision matching %s.' % revision
326 return update_deps(soln_path, dep_name, git_rev, comment) 326 return update_deps(soln_path, dep_name, git_rev, comment)
327 327
328 if __name__ == '__main__': 328 if __name__ == '__main__':
329 sys.exit(main(sys.argv[1:])) 329 sys.exit(main(sys.argv[1:]))
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