summaryrefslogtreecommitdiffstats
path: root/tools/sync-webkit-git.py
diff options
context:
space:
mode:
authorlevin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-27 16:53:17 +0000
committerlevin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-27 16:53:17 +0000
commit1224ad1d7aacd8cd49d57571458700e8020d0fa4 (patch)
tree66cdd5272e20c8d6b3effa7c137fda1194d63301 /tools/sync-webkit-git.py
parentc9dab4721645020374d6f73fabba6c68ec35000a (diff)
downloadchromium_src-1224ad1d7aacd8cd49d57571458700e8020d0fa4.zip
chromium_src-1224ad1d7aacd8cd49d57571458700e8020d0fa4.tar.gz
chromium_src-1224ad1d7aacd8cd49d57571458700e8020d0fa4.tar.bz2
Allow the branch name updated by sync-webkit-git.py to be overriden using the
git config in the WebKit directory. My scenario is that I have the same git repository (using git-new-workdir) under two different chromium enlistments. (Yes, even with git, I find it useful to have more than one enlistment at times.) BUG=None TEST=Did a run of the tool without the config set and with it set to an existing branch and a non-existing branch. Review URL: http://codereview.chromium.org/3239002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57690 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/sync-webkit-git.py')
-rwxr-xr-xtools/sync-webkit-git.py42
1 files changed, 30 insertions, 12 deletions
diff --git a/tools/sync-webkit-git.py b/tools/sync-webkit-git.py
index a54dfeb..a123ea2 100755
--- a/tools/sync-webkit-git.py
+++ b/tools/sync-webkit-git.py
@@ -1,5 +1,5 @@
#!/usr/bin/python
-# Copyright (c) 2009 The Chromium Authors. All rights reserved.
+# Copyright (c) 2010 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -17,10 +17,6 @@ import re
import subprocess
import sys
-# The name of the magic branch that lets us know that DEPS is managing
-# the update cycle.
-MAGIC_GCLIENT_BRANCH = 'refs/heads/gclient'
-
def RunGit(command):
"""Run a git subcommand, returning its output."""
# On Windows, use shell=True to get PATH interpretation.
@@ -29,6 +25,27 @@ def RunGit(command):
stdout=subprocess.PIPE)
return proc.communicate()[0].strip()
+def GetGClientBranchName():
+ """Returns the name of the magic branch that lets us know that DEPS is
+ managing the update cycle."""
+ # Is there an override branch specified?
+ overide_config_name = 'chromium.sync-branch'
+ override_branch_name = RunGit(['config', '--get', overide_config_name])
+ if not override_branch_name:
+ return 'refs/heads/gclient' # No override, so return the default branch.
+
+ # Verify that the branch from config exists.
+ ref_branch = 'refs/heads/' + override_branch_name
+ current_head = RunGit(['show-ref', '--hash', ref_branch])
+ if current_head:
+ return ref_branch
+
+ # Inform the user about the problem and how to fix it.
+ print ("The specified override branch ('%s') doesn't appear to exist." %
+ override_branch_name)
+ print "Please fix your git config value '%s'." % overide_config_name
+ sys.exit(1)
+
def GetWebKitRev():
"""Extract the 'webkit_revision' variable out of DEPS."""
locals = {'Var': lambda _: ''}
@@ -80,7 +97,7 @@ def FindSVNRev(target_rev):
print "Something has likely gone horribly wrong."
return None
-def UpdateGClientBranch(webkit_rev):
+def UpdateGClientBranch(webkit_rev, magic_gclient_branch):
"""Update the magic gclient branch to point at |webkit_rev|.
Returns: true if the branch didn't need changes."""
@@ -93,19 +110,19 @@ def UpdateGClientBranch(webkit_rev):
print "ERROR: Couldn't map r%s to a git revision." % webkit_rev
sys.exit(1)
- current = RunGit(['show-ref', '--hash', MAGIC_GCLIENT_BRANCH])
+ current = RunGit(['show-ref', '--hash', magic_gclient_branch])
if current == target:
return False # No change necessary.
subprocess.check_call(['git', 'update-ref', '-m', 'gclient sync',
- MAGIC_GCLIENT_BRANCH, target],
+ magic_gclient_branch, target],
shell=(os.name == 'nt'))
return True
-def UpdateCurrentCheckoutIfAppropriate():
+def UpdateCurrentCheckoutIfAppropriate(magic_gclient_branch):
"""Reset the current gclient branch if that's what we have checked out."""
branch = RunGit(['symbolic-ref', '-q', 'HEAD'])
- if branch != MAGIC_GCLIENT_BRANCH:
+ if branch != magic_gclient_branch:
print "We have now updated the 'gclient' branch, but third_party/WebKit"
print "has some other branch ('%s') checked out." % branch
print "Run 'git checkout gclient' under third_party/WebKit if you want"
@@ -132,9 +149,10 @@ def main():
webkit_rev = GetWebKitRev()
print 'Desired revision: r%s.' % webkit_rev
os.chdir('third_party/WebKit')
- changed = UpdateGClientBranch(webkit_rev)
+ magic_gclient_branch = GetGClientBranchName()
+ changed = UpdateGClientBranch(webkit_rev, magic_gclient_branch)
if changed:
- return UpdateCurrentCheckoutIfAppropriate()
+ return UpdateCurrentCheckoutIfAppropriate(magic_gclient_branch)
else:
print "Already on correct revision."
return 0