182c98161b9cd8e8f94e00d89b6fd56540473b3d4Torne (Richard Coles)#!/usr/bin/python 233e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles)# 333e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles)# Copyright (C) 2012 The Android Open Source Project 433e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles)# 533e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles)# Licensed under the Apache License, Version 2.0 (the "License"); 633e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles)# you may not use this file except in compliance with the License. 733e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles)# You may obtain a copy of the License at 833e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles)# 933e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles)# http://www.apache.org/licenses/LICENSE-2.0 1033e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles)# 1133e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles)# Unless required by applicable law or agreed to in writing, software 1233e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles)# distributed under the License is distributed on an "AS IS" BASIS, 1333e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles)# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1433e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles)# See the License for the specific language governing permissions and 1533e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles)# limitations under the License. 1633e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) 1782c98161b9cd8e8f94e00d89b6fd56540473b3d4Torne (Richard Coles)"""Merge master-chromium to master within the Android tree.""" 1833e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) 195d65b76f6747f51bb623d00205aca85581ad4d91Torne (Richard Coles)import logging 2033e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles)import optparse 2133e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles)import os 2233e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles)import re 2333e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles)import shutil 2433e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles)import sys 2533e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) 2633e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles)import merge_common 2733e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) 2833e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) 2933e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles)AUTOGEN_MESSAGE = 'This commit was generated by merge_to_master.py.' 3033e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) 3133e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) 326adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles)def _MergeProjects(svn_revision, target): 336adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles) """Merges the Chromium projects from master-chromium to target. 3482c98161b9cd8e8f94e00d89b6fd56540473b3d4Torne (Richard Coles) 3582c98161b9cd8e8f94e00d89b6fd56540473b3d4Torne (Richard Coles) The larger projects' histories are flattened in the process. 3682c98161b9cd8e8f94e00d89b6fd56540473b3d4Torne (Richard Coles) 3733e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) Args: 3833e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) svn_revision: The SVN revision for the main Chromium repository 3933e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) """ 4033e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) for path in merge_common.PROJECTS_WITH_FLAT_HISTORY: 4133e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) dest_dir = os.path.join(merge_common.REPOSITORY_ROOT, path) 4258324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) merge_common.GetCommandStdout(['git', 'remote', 'update', 4358324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) 'goog', 'history'], cwd=dest_dir) 4433e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) merge_common.GetCommandStdout(['git', 'checkout', 456adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles) '-b', 'merge-to-' + target, 466adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles) '-t', 'goog/' + target], cwd=dest_dir) 47e1a149c76208a84c7595203a465ae1218ded9d34Torne (Richard Coles) merge_common.GetCommandStdout(['git', 'fetch', 'history', 48e1a149c76208a84c7595203a465ae1218ded9d34Torne (Richard Coles) 'refs/archive/chromium-%s' % svn_revision], 49e1a149c76208a84c7595203a465ae1218ded9d34Torne (Richard Coles) cwd=dest_dir) 5033e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) merge_sha1 = merge_common.GetCommandStdout(['git', 'rev-parse', 51e1a149c76208a84c7595203a465ae1218ded9d34Torne (Richard Coles) 'FETCH_HEAD'], 5233e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) cwd=dest_dir).strip() 5333e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) old_sha1 = merge_common.GetCommandStdout(['git', 'rev-parse', 'HEAD'], 5433e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) cwd=dest_dir).strip() 5533e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) # Make the previous merges into grafts so we can do a correct merge. 5633e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) merge_log = os.path.join(dest_dir, '.merged-revisions') 5733e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) if os.path.exists(merge_log): 5833e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) shutil.copyfile(merge_log, 5933e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) os.path.join(dest_dir, '.git', 'info', 'grafts')) 6033e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) if merge_common.GetCommandStdout(['git', 'rev-list', '-1', 6133e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) 'HEAD..' + merge_sha1], cwd=dest_dir): 625d65b76f6747f51bb623d00205aca85581ad4d91Torne (Richard Coles) logging.debug('Merging project %s ...', path) 6333e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) # Merge conflicts cause 'git merge' to return 1, so ignore errors 6433e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) merge_common.GetCommandStdout(['git', 'merge', '--no-commit', '--squash', 6533e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) merge_sha1], 6633e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) cwd=dest_dir, ignore_errors=True) 6733e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) dirs_to_prune = merge_common.PRUNE_WHEN_FLATTENING.get(path, []) 6833e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) if dirs_to_prune: 6933e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) merge_common.GetCommandStdout(['git', 'rm', '--ignore-unmatch', '-rf'] + 7033e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) dirs_to_prune, cwd=dest_dir) 7133e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) merge_common.CheckNoConflictsAndCommitMerge( 7294addffe055d2df297d4cf6c981d13a6e0a62bbcTorne (Richard Coles) 'Merge from Chromium at DEPS revision %s\n\n%s' % 7333e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) (svn_revision, AUTOGEN_MESSAGE), cwd=dest_dir) 7433e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) new_sha1 = merge_common.GetCommandStdout(['git', 'rev-parse', 'HEAD'], 7533e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) cwd=dest_dir).strip() 7633e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) with open(merge_log, 'a+') as f: 7733e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) f.write('%s %s %s\n' % (new_sha1, old_sha1, merge_sha1)) 7833e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) merge_common.GetCommandStdout(['git', 'add', '.merged-revisions'], 7933e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) cwd=dest_dir) 8082c98161b9cd8e8f94e00d89b6fd56540473b3d4Torne (Richard Coles) merge_common.GetCommandStdout( 8182c98161b9cd8e8f94e00d89b6fd56540473b3d4Torne (Richard Coles) ['git', 'commit', '-m', 8294addffe055d2df297d4cf6c981d13a6e0a62bbcTorne (Richard Coles) 'Record Chromium merge at DEPS revision %s\n\n%s' % 8382c98161b9cd8e8f94e00d89b6fd56540473b3d4Torne (Richard Coles) (svn_revision, AUTOGEN_MESSAGE)], cwd=dest_dir) 8433e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) else: 855d65b76f6747f51bb623d00205aca85581ad4d91Torne (Richard Coles) logging.debug('No new commits to merge in project %s', path) 8633e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) 8733e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) for path in merge_common.PROJECTS_WITH_FULL_HISTORY: 8833e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) dest_dir = os.path.join(merge_common.REPOSITORY_ROOT, path) 8958324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) merge_common.GetCommandStdout(['git', 'remote', 'update', 'goog'], 9058324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) cwd=dest_dir) 9133e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) merge_common.GetCommandStdout(['git', 'checkout', 926adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles) '-b', 'merge-to-' + target, 936adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles) '-t', 'goog/' + target], cwd=dest_dir) 94e1a149c76208a84c7595203a465ae1218ded9d34Torne (Richard Coles) merge_common.GetCommandStdout(['git', 'fetch', 'goog', 95e1a149c76208a84c7595203a465ae1218ded9d34Torne (Richard Coles) 'refs/archive/chromium-%s' % svn_revision], 96e1a149c76208a84c7595203a465ae1218ded9d34Torne (Richard Coles) cwd=dest_dir) 9733e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) if merge_common.GetCommandStdout(['git', 'rev-list', '-1', 98e1a149c76208a84c7595203a465ae1218ded9d34Torne (Richard Coles) 'HEAD..FETCH_HEAD'], 9933e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) cwd=dest_dir): 1005d65b76f6747f51bb623d00205aca85581ad4d91Torne (Richard Coles) logging.debug('Merging project %s ...', path) 10133e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) # Merge conflicts cause 'git merge' to return 1, so ignore errors 10233e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) merge_common.GetCommandStdout(['git', 'merge', '--no-commit', '--no-ff', 103e1a149c76208a84c7595203a465ae1218ded9d34Torne (Richard Coles) 'FETCH_HEAD'], 10433e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) cwd=dest_dir, ignore_errors=True) 10533e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) merge_common.CheckNoConflictsAndCommitMerge( 10694addffe055d2df297d4cf6c981d13a6e0a62bbcTorne (Richard Coles) 'Merge from Chromium at DEPS revision %s\n\n%s' % 10733e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) (svn_revision, AUTOGEN_MESSAGE), cwd=dest_dir) 10833e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) else: 1095d65b76f6747f51bb623d00205aca85581ad4d91Torne (Richard Coles) logging.debug('No new commits to merge in project %s', path) 11033e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) 11133e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) 11258324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles)def _GetSVNRevision(commitish='history/master-chromium'): 1135d65b76f6747f51bb623d00205aca85581ad4d91Torne (Richard Coles) logging.debug('Getting SVN revision ...') 11433e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) commit = merge_common.GetCommandStdout([ 11558324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) 'git', 'log', '-n1', '--grep=git-svn-id:', '--format=%H%n%b', commitish]) 11633e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) svn_revision = re.search(r'^git-svn-id: .*@([0-9]+)', commit, 11733e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) flags=re.MULTILINE).group(1) 11833e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) return svn_revision 11933e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) 12033e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) 1216adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles)def _MergeWithRepoProp(repo_prop_file, target): 12258324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) chromium_sha = None 12358324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) webview_sha = None 12458324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) with open(repo_prop_file) as prop: 12558324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) for line in prop: 12658324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) project, sha = line.split() 12758324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) if project == 'platform/external/chromium_org-history': 12858324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) chromium_sha = sha 12958324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) elif project == 'platform/frameworks/webview': 13058324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) webview_sha = sha 13158324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) if not chromium_sha or not webview_sha: 13258324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) logging.error('SHA1s for projects not found; invalid build.prop?') 13358324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) return 1 13458324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) chromium_revision = _GetSVNRevision(chromium_sha) 13558324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) logging.info('Merging Chromium at r%s and WebView at %s', chromium_revision, 13658324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) webview_sha) 1376adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles) _MergeProjects(chromium_revision, target) 13858324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) 13958324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) dest_dir = os.path.join(os.environ['ANDROID_BUILD_TOP'], 'frameworks/webview') 14058324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) merge_common.GetCommandStdout(['git', 'remote', 'update', 'goog'], 14158324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) cwd=dest_dir) 14258324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) merge_common.GetCommandStdout(['git', 'checkout', 1436adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles) '-b', 'merge-to-' + target, 1446adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles) '-t', 'goog/' + target], cwd=dest_dir) 14558324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) if merge_common.GetCommandStdout(['git', 'rev-list', '-1', 14658324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) 'HEAD..' + webview_sha], cwd=dest_dir): 14758324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) logging.debug('Creating merge for framework...') 14858324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) # Merge conflicts cause 'git merge' to return 1, so ignore errors 14958324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) merge_common.GetCommandStdout(['git', 'merge', '--no-commit', '--no-ff', 15058324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) webview_sha], cwd=dest_dir, 15158324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) ignore_errors=True) 15258324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) merge_common.CheckNoConflictsAndCommitMerge( 1536adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles) 'Merge master-chromium into %s at r%s\n\n%s' % 1546adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles) (target, chromium_revision, AUTOGEN_MESSAGE), cwd=dest_dir) 15558324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) upload = merge_common.GetCommandStdout(['git', 'push', 'goog', 1566adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles) 'HEAD:refs/for/' + target], 15758324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) cwd=dest_dir) 1587fd1d813e7f206ff7a25ee8fca36c4cbe860b361Torne (Richard Coles) logging.info(upload) 15958324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) else: 16058324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) logging.debug('No new commits to merge in framework') 16158324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) return 0 16258324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) 16358324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) 1646adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles)def Push(target): 16509ead754abd2cfcffea54040b1c9ac98db8af834Torne (Richard Coles) """Push the finished snapshot to the Android repository.""" 16609ead754abd2cfcffea54040b1c9ac98db8af834Torne (Richard Coles) logging.debug('Pushing to server ...') 1676adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles) refspec = 'merge-to-%s:%s' % (target, target) 16809ead754abd2cfcffea54040b1c9ac98db8af834Torne (Richard Coles) for path in merge_common.ALL_PROJECTS: 16909ead754abd2cfcffea54040b1c9ac98db8af834Torne (Richard Coles) logging.debug('Pushing %s', path) 17009ead754abd2cfcffea54040b1c9ac98db8af834Torne (Richard Coles) dest_dir = os.path.join(merge_common.REPOSITORY_ROOT, path) 171e1a149c76208a84c7595203a465ae1218ded9d34Torne (Richard Coles) # Delete the graft before pushing otherwise git will attempt to push all the 172e1a149c76208a84c7595203a465ae1218ded9d34Torne (Richard Coles) # grafted-in objects to the server as well as the ones we want. 173e1a149c76208a84c7595203a465ae1218ded9d34Torne (Richard Coles) graftfile = os.path.join(dest_dir, '.git', 'info', 'grafts') 174e1a149c76208a84c7595203a465ae1218ded9d34Torne (Richard Coles) if os.path.exists(graftfile): 175e1a149c76208a84c7595203a465ae1218ded9d34Torne (Richard Coles) os.remove(graftfile) 1766adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles) merge_common.GetCommandStdout(['git', 'push', 'goog', refspec], 1776adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles) cwd=dest_dir) 17809ead754abd2cfcffea54040b1c9ac98db8af834Torne (Richard Coles) 17909ead754abd2cfcffea54040b1c9ac98db8af834Torne (Richard Coles) 18009ead754abd2cfcffea54040b1c9ac98db8af834Torne (Richard Coles) 18133e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles)def main(): 18233e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) parser = optparse.OptionParser(usage='%prog [options]') 18333e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) parser.epilog = ('Takes the current master-chromium branch of the Chromium ' 18433e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) 'projects in Android and merges them into master to publish ' 18533e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) 'them.') 18633e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) parser.add_option( 18794addffe055d2df297d4cf6c981d13a6e0a62bbcTorne (Richard Coles) '', '--svn_revision', '--release', 188e1a149c76208a84c7595203a465ae1218ded9d34Torne (Richard Coles) default=None, 189e1a149c76208a84c7595203a465ae1218ded9d34Torne (Richard Coles) help=('Merge to the specified archived master-chromium SVN revision,' 190e1a149c76208a84c7595203a465ae1218ded9d34Torne (Richard Coles) 'rather than using HEAD.')) 191e1a149c76208a84c7595203a465ae1218ded9d34Torne (Richard Coles) parser.add_option( 19258324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) '', '--repo-prop', 19358324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) default=None, metavar='FILE', 19458324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) help=('Merge to the revisions specified in this repo.prop file.')) 19558324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) parser.add_option( 19614ac2c8d49fa1f5f12e6a80af93f1c50312d80a8Torne (Richard Coles) '', '--push', 19782c98161b9cd8e8f94e00d89b6fd56540473b3d4Torne (Richard Coles) default=False, action='store_true', 19814ac2c8d49fa1f5f12e6a80af93f1c50312d80a8Torne (Richard Coles) help=('Push the result of a previous merge to the server.')) 1996adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles) parser.add_option( 2006adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles) '', '--target', 2016adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles) default='master', metavar='BRANCH', 2026adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles) help=('Target branch to push to. Defaults to master.')) 20333e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) (options, args) = parser.parse_args() 20433e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) if args: 20533e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) parser.print_help() 20633e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) return 1 20733e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) 2085d65b76f6747f51bb623d00205aca85581ad4d91Torne (Richard Coles) logging.basicConfig(format='%(message)s', level=logging.DEBUG, 2095d65b76f6747f51bb623d00205aca85581ad4d91Torne (Richard Coles) stream=sys.stdout) 2105d65b76f6747f51bb623d00205aca85581ad4d91Torne (Richard Coles) 21114ac2c8d49fa1f5f12e6a80af93f1c50312d80a8Torne (Richard Coles) if options.push: 2126adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles) Push(options.target) 21358324375a4ba319e7b114f3afece23a98de3f373Torne (Richard Coles) elif options.repo_prop: 2146adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles) return _MergeWithRepoProp(os.path.expanduser(options.repo_prop), 2156adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles) options.target) 216e1a149c76208a84c7595203a465ae1218ded9d34Torne (Richard Coles) elif options.svn_revision: 2176adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles) _MergeProjects(options.svn_revision, options.target) 21814ac2c8d49fa1f5f12e6a80af93f1c50312d80a8Torne (Richard Coles) else: 21914ac2c8d49fa1f5f12e6a80af93f1c50312d80a8Torne (Richard Coles) svn_revision = _GetSVNRevision() 2206adc8a2e72d90b3a5c1cf7cf7ec7be2f6c974851Torne (Richard Coles) _MergeProjects(svn_revision, options.target) 22182c98161b9cd8e8f94e00d89b6fd56540473b3d4Torne (Richard Coles) 22233e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) return 0 22333e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) 22433e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles)if __name__ == '__main__': 22533e5c69dc781743cc2560bef57763170b61bae3fTorne (Richard Coles) sys.exit(main()) 226