From 0281f52cf3ec64c9ddbbc864ed227d050fe6f425 Mon Sep 17 00:00:00 2001 From: "binji@chromium.org" Date: Fri, 14 Sep 2012 13:37:59 +0000 Subject: [PATCH] Running git cl patch sets the rietveld patchset. BUG=none Review URL: https://chromiumcodereview.appspot.com/10907229 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@156796 0039d316-1c4b-4281-b951-d872f2087c98 --- git_cl.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/git_cl.py b/git_cl.py index e894f08aa..29ee421ac 100755 --- a/git_cl.py +++ b/git_cl.py @@ -509,9 +509,11 @@ or verify this branch is set up to track another (via the --track argument to stderr=subprocess2.PIPE, error_ok=True) self.has_patchset = False - def GetPatchSetDiff(self, issue): - patchset = self.RpcServer().get_issue_properties( + def GetMostRecentPatchset(self, issue): + return self.RpcServer().get_issue_properties( int(issue), False)['patchsets'][-1] + + def GetPatchSetDiff(self, issue, patchset): return self.RpcServer().get( '/download/issue%s_%s.diff' % (issue, patchset)) @@ -1403,16 +1405,19 @@ def CMDpatch(parser, args): if issue_arg.isdigit(): # Input is an issue id. Figure out the URL. + cl = Changelist() issue = int(issue_arg) - patch_data = Changelist().GetPatchSetDiff(issue) + patchset = cl.GetMostRecentPatchset(issue) + patch_data = cl.GetPatchSetDiff(issue, patchset) else: # Assume it's a URL to the patch. Default to https. issue_url = gclient_utils.UpgradeToHttps(issue_arg) - match = re.match(r'.*?/issue(\d+)_\d+.diff', issue_url) + match = re.match(r'.*?/issue(\d+)_(\d+).diff', issue_url) if not match: DieWithError('Must pass an issue ID or full URL for ' '\'Download raw patch set\'') issue = int(match.group(1)) + patchset = int(match.group(2)) patch_data = urllib2.urlopen(issue_arg).read() if options.newbranch: @@ -1454,6 +1459,7 @@ def CMDpatch(parser, args): RunGit(['commit', '-m', 'patch from issue %s' % issue]) cl = Changelist() cl.SetIssue(issue) + cl.SetPatchset(patchset) print "Committed patch." else: print "Patch applied to index." @@ -1587,8 +1593,7 @@ def CMDtry(parser, args): patchset = cl.GetPatchset() if not cl.GetPatchset(): - properties = cl.RpcServer().get_issue_properties(cl.GetIssue(), False) - patchset = properties['patchsets'][-1] + patchset = cl.GetMostRecentPatchset(cl.GetIssue()) cl.RpcServer().trigger_try_jobs( cl.GetIssue(), patchset, options.name, options.clobber, options.revision,