From d067d81657f69a06a4a561639233b6caa528b00d Mon Sep 17 00:00:00 2001 From: "hinoka@google.com" Date: Fri, 21 Feb 2014 02:23:14 +0000 Subject: [PATCH] Apply Issue changes for disabling checkout when bot update ran. This add --force to ignore the flag file. This also passes --base_ref so we can specify which ref we're basing off of so that it does not incorrectly assert that it is basing off origin/master BUG=339171 Review URL: https://codereview.chromium.org/171763003 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@252464 0039d316-1c4b-4281-b951-d872f2087c98 --- apply_issue.py | 13 ++++++++++++- checkout.py | 11 ++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/apply_issue.py b/apply_issue.py index c8cbfec32..b4ad8946f 100755 --- a/apply_issue.py +++ b/apply_issue.py @@ -72,7 +72,17 @@ def main(): parser.add_option('--revision-mapping', default='{}', help='When running gclient, annotate the got_revisions ' 'using the revision-mapping.') + parser.add_option('-f', '--force', action='store_true', + help='Really run apply_issue, even if .update.flag ' + 'is detected.') + parser.add_option('-b', '--base_ref', help='Base git ref to patch on top of, ' + 'used for verification.') options, args = parser.parse_args() + if (os.path.isfile(os.path.join(os.getcwd(), 'update.flag')) + and not options.force): + print 'update.flag file found: bot_update has run and checkout is already ' + print 'in a consistent state. No actions will be performed in this step.' + return 0 logging.basicConfig( format='%(levelname)5s %(module)11s(%(lineno)4d): %(message)s', level=[logging.WARNING, logging.INFO, logging.DEBUG][ @@ -151,7 +161,8 @@ def main(): if scm_type == 'svn': scm_obj = checkout.SvnCheckout(full_dir, None, None, None, None) elif scm_type == 'git': - scm_obj = checkout.GitCheckout(full_dir, None, None, None, None) + scm_obj = checkout.GitCheckout(full_dir, None, None, None, None, + base_ref=options.base_ref) elif scm_type == None: scm_obj = checkout.RawCheckout(full_dir, None, None) else: diff --git a/checkout.py b/checkout.py index 450b37973..cc570082c 100644 --- a/checkout.py +++ b/checkout.py @@ -553,8 +553,9 @@ class SvnCheckout(CheckoutBase, SvnMixIn): class GitCheckout(CheckoutBase): """Manages a git checkout.""" def __init__(self, root_dir, project_name, remote_branch, git_url, - commit_user, post_processors=None): + commit_user, post_processors=None, base_ref=None): super(GitCheckout, self).__init__(root_dir, project_name, post_processors) + self.base_ref = base_ref self.git_url = git_url self.commit_user = commit_user self.remote_branch = remote_branch @@ -710,9 +711,13 @@ class GitCheckout(CheckoutBase): if verbose: cmd.append('--verbose') self._check_call_git(cmd) + if self.base_ref: + base_ref = self.base_ref + else: + base_ref = '%s/%s' % (self.remote, + self.remote_branch or self.master_branch) found_files = self._check_output_git( - ['diff', '%s/%s' % (self.remote, - self.remote_branch or self.master_branch), + ['diff', base_ref, '--name-only']).splitlines(False) assert sorted(patches.filenames) == sorted(found_files), ( sorted(patches.filenames), sorted(found_files))