Commit 1c28dab9 authored by rmistry@google.com's avatar rmistry@google.com

Revert of [depot_tools] Find, upload and apply patchset dependencies (patchset...

Revert of [depot_tools] Find, upload and apply patchset dependencies (patchset #17 id:360001 of https://codereview.chromium.org/1149653002/)

Reason for revert:
Ran into a crash during the bot_update step here:
https://uberchromegw.corp.google.com/i/internal.infra.try/builders/infra-internal-presubmit/builds/62

Original issue's description:
> Find, upload and apply patchset dependencies.
> 
> Here is an explanation of the changes in each module:
> 
> * git_cl.py -
> IF a local branch is being tracked AND a CL has been uploaded there THEN use the CL's issue number and latest patchset as a dependency.
> 
> * upload.py -
> Uploads the patchset dependency, if it exists, to Rietveld (Rietveld will be able to parse this when https://codereview.chromium.org/1155513002/ lands).
> 
> * rietveld.py -
> Adds utility methods to get patchset dependencies from the new Rietveld endpoint (the endpoint will exist when https://codereview.chromium.org/1155513002/ lands).
> 
> * apply_issue.py -
> If CL3 depends on CL2 which in turn depends on CL1 then apply_issue will gather a list of all issues and patchsets to apply (Eg: [CL1:PS1, CL2:PS1, CL3:PS2]).
> apply_issue will then loop over the list applying each dependency.
> Note: The apply_issue.py diff looks much worse than it is. Please see my comment in
> https://codereview.chromium.org/1149653002/diff/260001/apply_issue.py#oldcode169
> 
> 
> Tested end-to-end using a test Git repository (https://skia.googlesource.com/skiabot-test/) and the following CLs created in my test Rietveld instance:
> * https://skia-codereview-staging.appspot.com/931002  ('Branch1 CL')
> * https://skia-codereview-staging.appspot.com/5001001 ('Branch2 CL')
> * https://skia-codereview-staging.appspot.com/9881001 ('Branch3 CL')
> * https://skia-codereview-staging.appspot.com/3951001 ('Branch3.1 CL')
> Opt into the new UI and observe the new 'Depends on Patchset' and 'Dependent Patchsets' sections in the above CLs.
> 
> 
> Design doc is here: https://docs.google.com/document/d/1KZGFKZpOPvco81sYVRCzwlnjGctup71RAzY0MSb0ntc/edit#heading=h.6r6lt4tsvssw
> 
> BUG=502255
> 
> Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=295778

TBR=agable@chromium.org,jrobbins@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=502255

Review URL: https://codereview.chromium.org/1200773003

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@295782 0039d316-1c4b-4281-b951-d872f2087c98
parent 2dd99862
...@@ -166,86 +166,52 @@ def main(): ...@@ -166,86 +166,52 @@ def main():
options.patchset = properties['patchsets'][-1] options.patchset = properties['patchsets'][-1]
print('No patchset specified. Using patchset %d' % options.patchset) print('No patchset specified. Using patchset %d' % options.patchset)
issues_patchsets_to_apply = [(options.issue, options.patchset)] print('Downloading the patch.')
depends_on_info = obj.get_depends_on_patchset(options.issue, options.patchset) try:
while depends_on_info: patchset = obj.get_patch(options.issue, options.patchset)
depends_on_issue = int(depends_on_info['issue']) except urllib2.HTTPError as e:
depends_on_patchset = int(depends_on_info['patchset']) print(
try: 'Failed to fetch the patch for issue %d, patchset %d.\n'
depends_on_info = obj.get_depends_on_patchset(depends_on_issue, 'Try visiting %s/%d') % (
depends_on_patchset) options.issue, options.patchset,
issues_patchsets_to_apply.insert(0, (depends_on_issue, options.server, options.issue)
depends_on_patchset)) return 1
except urllib2.HTTPError: if options.whitelist:
print ('The patchset that was marked as a dependency no longer ' patchset.patches = [patch for patch in patchset.patches
'exists: %s/%d/#ps%d' % ( if patch.filename in options.whitelist]
options.server, depends_on_issue, depends_on_patchset)) if options.blacklist:
print 'Therefore it is likely that this patch will not apply cleanly.' patchset.patches = [patch for patch in patchset.patches
print if patch.filename not in options.blacklist]
depends_on_info = None for patch in patchset.patches:
print(patch)
num_issues_patchsets_to_apply = len(issues_patchsets_to_apply) full_dir = os.path.abspath(options.root_dir)
if num_issues_patchsets_to_apply > 1: scm_type = scm.determine_scm(full_dir)
print if scm_type == 'svn':
print 'apply_issue.py found %d dependent CLs.' % ( scm_obj = checkout.SvnCheckout(full_dir, None, None, None, None)
num_issues_patchsets_to_apply - 1) elif scm_type == 'git':
print 'They will be applied in the following order:' scm_obj = checkout.GitCheckout(full_dir, None, None, None, None)
num = 1 elif scm_type == None:
for issue_to_apply, patchset_to_apply in issues_patchsets_to_apply: scm_obj = checkout.RawCheckout(full_dir, None, None)
print ' #%d %s/%d/#ps%d' % ( else:
num, options.server, issue_to_apply, patchset_to_apply) parser.error('Couldn\'t determine the scm')
num += 1
print # TODO(maruel): HACK, remove me.
# When run a build slave, make sure buildbot knows that the checkout was
for issue_to_apply, patchset_to_apply in issues_patchsets_to_apply: # modified.
issue_url = '%s/%d/#ps%d' % (options.server, issue_to_apply, if options.root_dir == 'src' and getpass.getuser() == 'chrome-bot':
patchset_to_apply) # See sourcedirIsPatched() in:
print('Downloading patch from %s' % issue_url) # http://src.chromium.org/viewvc/chrome/trunk/tools/build/scripts/slave/
try: # chromium_commands.py?view=markup
patchset = obj.get_patch(issue_to_apply, patchset_to_apply) open('.buildbot-patched', 'w').close()
except urllib2.HTTPError as e:
print( print('\nApplying the patch.')
'Failed to fetch the patch for issue %d, patchset %d.\n' try:
'Try visiting %s/%d') % ( scm_obj.apply_patch(patchset, verbose=True)
issue_to_apply, patchset_to_apply, except checkout.PatchApplicationFailed as e:
options.server, issue_to_apply) print(str(e))
return 1 print('CWD=%s' % os.getcwd())
if options.whitelist: print('Checkout path=%s' % scm_obj.project_path)
patchset.patches = [patch for patch in patchset.patches return 1
if patch.filename in options.whitelist]
if options.blacklist:
patchset.patches = [patch for patch in patchset.patches
if patch.filename not in options.blacklist]
for patch in patchset.patches:
print(patch)
full_dir = os.path.abspath(options.root_dir)
scm_type = scm.determine_scm(full_dir)
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)
elif scm_type == None:
scm_obj = checkout.RawCheckout(full_dir, None, None)
else:
parser.error('Couldn\'t determine the scm')
# TODO(maruel): HACK, remove me.
# When run a build slave, make sure buildbot knows that the checkout was
# modified.
if options.root_dir == 'src' and getpass.getuser() == 'chrome-bot':
# See sourcedirIsPatched() in:
# http://src.chromium.org/viewvc/chrome/trunk/tools/build/scripts/slave/
# chromium_commands.py?view=markup
open('.buildbot-patched', 'w').close()
print('\nApplying the patch from %s' % issue_url)
try:
scm_obj.apply_patch(patchset, verbose=True)
except checkout.PatchApplicationFailed as e:
print(str(e))
print('CWD=%s' % os.getcwd())
print('Checkout path=%s' % scm_obj.project_path)
return 1
if ('DEPS' in map(os.path.basename, patchset.filenames) if ('DEPS' in map(os.path.basename, patchset.filenames)
and not options.ignore_deps): and not options.ignore_deps):
......
...@@ -2185,28 +2185,6 @@ def RietveldUpload(options, args, cl, change): ...@@ -2185,28 +2185,6 @@ def RietveldUpload(options, args, cl, change):
if target_ref: if target_ref:
upload_args.extend(['--target_ref', target_ref]) upload_args.extend(['--target_ref', target_ref])
# Look for dependent patchsets. See crbug.com/480453 for more details.
remote, upstream_branch = cl.FetchUpstreamTuple(cl.GetBranch())
upstream_branch = ShortBranchName(upstream_branch)
if remote is '.':
# A local branch is being tracked.
local_branch = ShortBranchName(upstream_branch)
auth_config = auth.extract_auth_config_from_options(options)
branch_cl = Changelist(branchref=local_branch, auth_config=auth_config)
branch_cl_issue_url = branch_cl.GetIssueURL()
branch_cl_issue = branch_cl.GetIssue()
branch_cl_patchset = branch_cl.GetPatchset()
if branch_cl_issue_url and branch_cl_issue and branch_cl_patchset:
upload_args.extend(
['--depends_on_patchset', '%s:%s' % (
branch_cl_issue, branch_cl_patchset)])
print
print ('The current branch (%s) is tracking a local branch (%s) with '
'an open CL.') % (cl.GetBranch(), local_branch)
print 'Adding %s/#ps%s as a dependency patchset.' % (
branch_cl_issue_url, branch_cl_patchset)
print
project = settings.GetProject() project = settings.GetProject()
if project: if project:
upload_args.extend(['--project', project]) upload_args.extend(['--project', project])
......
...@@ -84,20 +84,6 @@ class Rietveld(object): ...@@ -84,20 +84,6 @@ class Rietveld(object):
data['description'] = '\n'.join(data['description'].strip().splitlines()) data['description'] = '\n'.join(data['description'].strip().splitlines())
return data return data
def get_depends_on_patchset(self, issue, patchset):
"""Returns the patchset this patchset depends on if it exists."""
url = '/%d/patchset/%d/get_depends_on_patchset' % (issue, patchset)
resp = None
try:
resp = json.loads(self.get(url))
except urllib2.HTTPError:
# The get_depends_on_patchset endpoint does not exist on this Rietveld
# instance yet. Ignore the error and proceed.
# TODO(rmistry): Make this an error when all Rietveld instances have
# this endpoint.
pass
return resp
def get_patchset_properties(self, issue, patchset): def get_patchset_properties(self, issue, patchset):
"""Returns the patchset properties.""" """Returns the patchset properties."""
url = '/api/%d/%d' % (issue, patchset) url = '/api/%d/%d' % (issue, patchset)
...@@ -691,9 +677,6 @@ class ReadOnlyRietveld(object): ...@@ -691,9 +677,6 @@ class ReadOnlyRietveld(object):
def get_patchset_properties(self, issue, patchset): def get_patchset_properties(self, issue, patchset):
return self._rietveld.get_patchset_properties(issue, patchset) return self._rietveld.get_patchset_properties(issue, patchset)
def get_depends_on_patchset(self, issue, patchset):
return self._rietveld.get_depends_on_patchset(issue, patchset)
def get_patch(self, issue, patchset): def get_patch(self, issue, patchset):
return self._rietveld.get_patch(issue, patchset) return self._rietveld.get_patch(issue, patchset)
......
...@@ -635,10 +635,6 @@ group.add_option("--target_ref", action="store", dest="target_ref", ...@@ -635,10 +635,6 @@ group.add_option("--target_ref", action="store", dest="target_ref",
parser.add_option("--cq_dry_run", action="store_true", parser.add_option("--cq_dry_run", action="store_true",
help="Send the patchset to do a CQ dry run right after " help="Send the patchset to do a CQ dry run right after "
"upload.") "upload.")
parser.add_option("--depends_on_patchset", action="store",
dest="depends_on_patchset",
help="The uploaded patchset this patchset depends on. The "
"value will be in this format- issue_num:patchset_num")
group.add_option("--download_base", action="store_true", group.add_option("--download_base", action="store_true",
dest="download_base", default=False, dest="download_base", default=False,
help="Base files will be downloaded by the server " help="Base files will be downloaded by the server "
...@@ -2440,8 +2436,6 @@ def RealMain(argv, data=None): ...@@ -2440,8 +2436,6 @@ def RealMain(argv, data=None):
if options.cq_dry_run: if options.cq_dry_run:
form_fields.append(("cq_dry_run", "1")) form_fields.append(("cq_dry_run", "1"))
form_fields.append(("commit", "1")) form_fields.append(("commit", "1"))
if options.depends_on_patchset:
form_fields.append(("depends_on_patchset", options.depends_on_patchset))
# Process --message, --title and --file. # Process --message, --title and --file.
message = options.message or "" message = options.message or ""
......
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