Commit d067d816 authored by hinoka@google.com's avatar hinoka@google.com

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
parent e0faffa4
...@@ -72,7 +72,17 @@ def main(): ...@@ -72,7 +72,17 @@ def main():
parser.add_option('--revision-mapping', default='{}', parser.add_option('--revision-mapping', default='{}',
help='When running gclient, annotate the got_revisions ' help='When running gclient, annotate the got_revisions '
'using the revision-mapping.') '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() 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( logging.basicConfig(
format='%(levelname)5s %(module)11s(%(lineno)4d): %(message)s', format='%(levelname)5s %(module)11s(%(lineno)4d): %(message)s',
level=[logging.WARNING, logging.INFO, logging.DEBUG][ level=[logging.WARNING, logging.INFO, logging.DEBUG][
...@@ -151,7 +161,8 @@ def main(): ...@@ -151,7 +161,8 @@ def main():
if scm_type == 'svn': if scm_type == 'svn':
scm_obj = checkout.SvnCheckout(full_dir, None, None, None, None) scm_obj = checkout.SvnCheckout(full_dir, None, None, None, None)
elif scm_type == 'git': 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: elif scm_type == None:
scm_obj = checkout.RawCheckout(full_dir, None, None) scm_obj = checkout.RawCheckout(full_dir, None, None)
else: else:
......
...@@ -553,8 +553,9 @@ class SvnCheckout(CheckoutBase, SvnMixIn): ...@@ -553,8 +553,9 @@ class SvnCheckout(CheckoutBase, SvnMixIn):
class GitCheckout(CheckoutBase): class GitCheckout(CheckoutBase):
"""Manages a git checkout.""" """Manages a git checkout."""
def __init__(self, root_dir, project_name, remote_branch, git_url, 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) super(GitCheckout, self).__init__(root_dir, project_name, post_processors)
self.base_ref = base_ref
self.git_url = git_url self.git_url = git_url
self.commit_user = commit_user self.commit_user = commit_user
self.remote_branch = remote_branch self.remote_branch = remote_branch
...@@ -710,9 +711,13 @@ class GitCheckout(CheckoutBase): ...@@ -710,9 +711,13 @@ class GitCheckout(CheckoutBase):
if verbose: if verbose:
cmd.append('--verbose') cmd.append('--verbose')
self._check_call_git(cmd) 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( found_files = self._check_output_git(
['diff', '%s/%s' % (self.remote, ['diff', base_ref,
self.remote_branch or self.master_branch),
'--name-only']).splitlines(False) '--name-only']).splitlines(False)
assert sorted(patches.filenames) == sorted(found_files), ( assert sorted(patches.filenames) == sorted(found_files), (
sorted(patches.filenames), sorted(found_files)) sorted(patches.filenames), sorted(found_files))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment