diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-01 17:50:24 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-01 17:50:24 +0000 |
commit | 3e02aa421fe3f1358602f7b8a47b1d9542ca6de2 (patch) | |
tree | a65be6c319edafcc6232fa66a7f114e41ea1e7a9 /tools/sync-webkit-git.py | |
parent | a189eb230939a522cd8e904519c4e2a1d97510f2 (diff) | |
download | chromium_src-3e02aa421fe3f1358602f7b8a47b1d9542ca6de2.zip chromium_src-3e02aa421fe3f1358602f7b8a47b1d9542ca6de2.tar.gz chromium_src-3e02aa421fe3f1358602f7b8a47b1d9542ca6de2.tar.bz2 |
Enhance sync-webkit-git.py to support more actions.
-r/--revision: desired revision. Use DEPS if not given.
-b/--branch: branch where to create gclient. Use origin/master if not given.
-t/--tarball: Use tarball (http://src.chromium.org/svn/releases/) DEPS instead of src/DEPS.
BUG=none
TEST=
./tools/sync-webkit-git.py -r 97678
./tools/sync-webkit-git.py -t 16.0.912.41 -b origin/svn_912
Review URL: http://codereview.chromium.org/8769001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112481 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/sync-webkit-git.py')
-rwxr-xr-x | tools/sync-webkit-git.py | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/tools/sync-webkit-git.py b/tools/sync-webkit-git.py index 4b98d9c..3c7c548 100755 --- a/tools/sync-webkit-git.py +++ b/tools/sync-webkit-git.py @@ -18,6 +18,7 @@ import os import re import subprocess import sys +import urllib def RunGit(command): @@ -67,7 +68,16 @@ def GetWebKitRev(): return locals['vars']['webkit_revision'] -def FindSVNRev(target_rev): +def GetWebKitRevFromTarball(version): + """Extract the 'webkit_revision' variable out of tarball DEPS.""" + deps_url = "http://src.chromium.org/svn/releases/" + version + "/DEPS" + f = urllib.urlopen(deps_url) + s = f.read() + m = re.search('(?<=/Source@)\w+', s) + return m.group(0) + + +def FindSVNRev(branch_name, target_rev): """Map an SVN revision to a git hash. Like 'git svn find-rev' but without the git-svn bits.""" @@ -82,8 +92,10 @@ def FindSVNRev(target_rev): commit_re = re.compile(r'^commit ([a-f\d]{40})$') # regexp matching the git-svn line from the log. git_svn_re = re.compile(r'^\s+git-svn-id: [^@]+@(\d+) ') + if not branch_name: + branch_name = 'origin/master' cmd = ['git', 'log', '--no-color', '--first-parent', '--pretty=medium', - 'origin/master'] + branch_name] logging.info(' '.join(cmd)) log = subprocess.Popen(cmd, shell=(os.name == 'nt'), stdout=subprocess.PIPE) # Track whether we saw a revision *later* than the one we're seeking. @@ -123,16 +135,16 @@ def GetRemote(): return 'origin' -def UpdateGClientBranch(webkit_rev, magic_gclient_branch): +def UpdateGClientBranch(branch_name, webkit_rev, magic_gclient_branch): """Update the magic gclient branch to point at |webkit_rev|. Returns: true if the branch didn't need changes.""" - target = FindSVNRev(webkit_rev) + target = FindSVNRev(branch_name, webkit_rev) if not target: print "r%s not available; fetching." % webkit_rev subprocess.check_call(['git', 'fetch', GetRemote()], shell=(os.name == 'nt')) - target = FindSVNRev(webkit_rev) + target = FindSVNRev(branch_name, webkit_rev) if not target: print "ERROR: Couldn't map r%s to a git revision." % webkit_rev sys.exit(1) @@ -166,6 +178,9 @@ def UpdateCurrentCheckoutIfAppropriate(magic_gclient_branch): def main(): parser = optparse.OptionParser() parser.add_option('-v', '--verbose', action='store_true') + parser.add_option('-r', '--revision', help="switch to desired revision") + parser.add_option('-t', '--tarball', help="switch to desired tarball release") + parser.add_option('-b', '--branch', help="branch name that gclient generate") options, args = parser.parse_args() if options.verbose: logging.basicConfig(level=logging.INFO) @@ -180,11 +195,21 @@ def main(): print "setup instructions." return 1 - webkit_rev = GetWebKitRev() + if options.revision: + webkit_rev = options.revision + if options.tarball: + print "WARNING: --revision is given, so ignore --tarball" + else: + if options.tarball: + webkit_rev = GetWebKitRevFromTarball(options.tarball) + else: + webkit_rev = GetWebKitRev() + print 'Desired revision: r%s.' % webkit_rev os.chdir('third_party/WebKit') magic_gclient_branch = GetGClientBranchName() - changed = UpdateGClientBranch(webkit_rev, magic_gclient_branch) + changed = UpdateGClientBranch(options.branch, webkit_rev, + magic_gclient_branch) if changed: return UpdateCurrentCheckoutIfAppropriate(magic_gclient_branch) else: |