summaryrefslogtreecommitdiffstats
path: root/tools/safely-roll-deps.py
diff options
context:
space:
mode:
authorborenet@google.com <borenet@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-08 21:08:42 +0000
committerborenet@google.com <borenet@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-08 21:08:42 +0000
commit4f220fba8316adffeace8350d6cffaaa9c669aad (patch)
treef12d3b2cb785266f61d9e089f3f8718d480de5aa /tools/safely-roll-deps.py
parentc6b0af9a4f09916ecd48ba3870a9ea83c3bcabe9 (diff)
downloadchromium_src-4f220fba8316adffeace8350d6cffaaa9c669aad.zip
chromium_src-4f220fba8316adffeace8350d6cffaaa9c669aad.tar.gz
chromium_src-4f220fba8316adffeace8350d6cffaaa9c669aad.tar.bz2
safely-roll-deps: add --force flag to fix the local checkout if needed
NOTRY=true BUG=skia:1945 Review URL: https://codereview.chromium.org/222603004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262507 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/safely-roll-deps.py')
-rwxr-xr-xtools/safely-roll-deps.py28
1 files changed, 24 insertions, 4 deletions
diff --git a/tools/safely-roll-deps.py b/tools/safely-roll-deps.py
index 7163d43..23638b9 100755
--- a/tools/safely-roll-deps.py
+++ b/tools/safely-roll-deps.py
@@ -51,6 +51,9 @@ def main():
description=sys.modules[__name__].__doc__)
parser.add_option('-v', '--verbose', action='count', default=0)
parser.add_option('--dry-run', action='store_true')
+ parser.add_option('-f', '--force', action='store_true',
+ help='Make destructive changes to the local checkout if '
+ 'necessary.')
parser.add_option('--commit', action='store_true', default=True,
help='(default) Put change in commit queue on upload.')
parser.add_option('--no-commit', action='store_false', dest='commit',
@@ -83,15 +86,32 @@ def main():
# Silence the editor.
os.environ['EDITOR'] = 'true'
+ if options.force and not options.dry_run:
+ subprocess2.check_call(['git', 'clean', '-d', '-f'])
+ subprocess2.check_call(['git', 'rebase', '--abort'])
+
old_branch = scm.GIT.GetBranch(root_dir)
new_branch = '%s_roll' % project
+
+ if options.upstream == new_branch:
+ parser.error('Cannot set %s as its own upstream.' % new_branch)
+
if old_branch == new_branch:
- parser.error('Please delete the branch %s and move to a different branch'
- % new_branch)
+ if options.force:
+ if not options.dry_run:
+ subprocess2.check_call(['git', 'checkout', options.upstream, '-f'])
+ subprocess2.call(['git', 'branch', '-D', old_branch])
+ else:
+ parser.error('Please delete the branch %s and move to a different branch'
+ % new_branch)
if not options.dry_run:
- subprocess2.check_output(
- ['git', 'checkout', '-b', new_branch, options.upstream])
+ subprocess2.check_call(['git', 'fetch', 'origin'])
+ subprocess2.call(['git', 'svn', 'fetch'])
+ branch_cmd = ['git', 'checkout', '-b', new_branch, options.upstream]
+ if options.force:
+ branch_cmd.append('-f')
+ subprocess2.check_output(branch_cmd)
try:
old_rev = int(process_deps(os.path.join(root_dir, 'DEPS'), project, new_rev,