summaryrefslogtreecommitdiffstats
path: root/tools/sync-webkit-git.py
diff options
context:
space:
mode:
authormaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-29 17:25:34 +0000
committermaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-29 17:25:34 +0000
commitcb155a802bdc49cfafea1c41e0f0a92168f1da09 (patch)
treebf0fae4855c7f4458d8e959455b9d12d6cd54d9d /tools/sync-webkit-git.py
parent9bec23957253b83955c4096903ad6293d1c6e1bb (diff)
downloadchromium_src-cb155a802bdc49cfafea1c41e0f0a92168f1da09.zip
chromium_src-cb155a802bdc49cfafea1c41e0f0a92168f1da09.tar.gz
chromium_src-cb155a802bdc49cfafea1c41e0f0a92168f1da09.tar.bz2
Fix python scripts in src/tools/
Make sure that: - shebang is only present for executable files - shebang is #!/usr/bin/env python - __main__ is only present for executable files - file's executable bit is coherent Also fix EOF LF to be only one. TBR=timurrrr@chromium.org BUG=105108 TEST= Review URL: http://codereview.chromium.org/8678023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111960 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/sync-webkit-git.py')
-rwxr-xr-xtools/sync-webkit-git.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/tools/sync-webkit-git.py b/tools/sync-webkit-git.py
index 4a99886..4b98d9c 100755
--- a/tools/sync-webkit-git.py
+++ b/tools/sync-webkit-git.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
# Copyright (c) 2011 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.
@@ -19,6 +19,7 @@ import re
import subprocess
import sys
+
def RunGit(command):
"""Run a git subcommand, returning its output."""
# On Windows, use shell=True to get PATH interpretation.
@@ -30,11 +31,13 @@ def RunGit(command):
logging.info('Returned "%s"' % out)
return out
+
def GetOverrideShortBranchName():
"""Returns the user-configured override branch name, if any."""
override_config_name = 'chromium.sync-branch'
return RunGit(['config', '--get', override_config_name])
+
def GetGClientBranchName():
"""Returns the name of the magic branch that lets us know that DEPS is
managing the update cycle."""
@@ -55,6 +58,7 @@ def GetGClientBranchName():
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 _: locals["vars"][_],
@@ -62,6 +66,7 @@ def GetWebKitRev():
execfile('DEPS', {}, locals)
return locals['vars']['webkit_revision']
+
def FindSVNRev(target_rev):
"""Map an SVN revision to a git hash.
Like 'git svn find-rev' but without the git-svn bits."""
@@ -106,6 +111,7 @@ def FindSVNRev(target_rev):
print "Something has likely gone horribly wrong."
return None
+
def GetRemote():
branch = GetOverrideShortBranchName()
if not branch:
@@ -116,6 +122,7 @@ def GetRemote():
return remote
return 'origin'
+
def UpdateGClientBranch(webkit_rev, magic_gclient_branch):
"""Update the magic gclient branch to point at |webkit_rev|.
@@ -139,6 +146,7 @@ def UpdateGClientBranch(webkit_rev, magic_gclient_branch):
shell=(os.name == 'nt'))
return True
+
def UpdateCurrentCheckoutIfAppropriate(magic_gclient_branch):
"""Reset the current gclient branch if that's what we have checked out."""
branch = RunGit(['symbolic-ref', '-q', 'HEAD'])
@@ -154,6 +162,7 @@ def UpdateCurrentCheckoutIfAppropriate(magic_gclient_branch):
print "Resetting tree state to new revision."
subprocess.check_call(['git', 'reset', '--hard'], shell=(os.name == 'nt'))
+
def main():
parser = optparse.OptionParser()
parser.add_option('-v', '--verbose', action='store_true')
@@ -182,5 +191,6 @@ def main():
print "Already on correct revision."
return 0
+
if __name__ == '__main__':
sys.exit(main())