From ef7c68c57f20196b27b2059cd28f5f28bb22435a Mon Sep 17 00:00:00 2001 From: "tandrii@chromium.org" <tandrii@chromium.org> Date: Thu, 7 Apr 2016 09:39:39 +0000 Subject: [PATCH] git cl diff: fix regression. Reported in https://codereview.chromium.org/1852803002/#msg5. Also some cleanup in nearby code AND fix of the git cl diff's previous behavior that actually updated local branch config with latest *uploaded* CL values. BUG=579182 R=machenbach@chromium.org,andybons@chromium.org CC=servolk@chromium.org Review URL: https://codereview.chromium.org/1871463003 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@299759 0039d316-1c4b-4281-b951-d872f2087c98 --- git_cl.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/git_cl.py b/git_cl.py index 98d9c6737..fb12eafe9 100755 --- a/git_cl.py +++ b/git_cl.py @@ -1297,8 +1297,8 @@ class Changelist(object): def CMDPatchIssue(self, issue_arg, reject, nocommit, directory): """Fetches and applies the issue patch from codereview to local branch.""" - if issue_arg.isdigit(): - parsed_issue_arg = _RietveldParsedIssueNumberArgument(int(issue_arg)) + if isinstance(issue_arg, (int, long)) or issue_arg.isdigit(): + parsed_issue_arg = _ParsedIssueNumberArgument(int(issue_arg)) else: # Assume url. parsed_issue_arg = self._codereview_impl.ParseIssueURL( @@ -1603,7 +1603,8 @@ class _RietveldChangelistImpl(_ChangelistCodereviewBase): if parsed_issue_arg.hostname: self._rietveld_server = 'https://%s' % parsed_issue_arg.hostname - if parsed_issue_arg.patch_url: + if (isinstance(parsed_issue_arg, _RietveldParsedIssueNumberArgument) and + parsed_issue_arg.patch_url): assert parsed_issue_arg.patchset patchset = parsed_issue_arg.patchset patch_data = urllib2.urlopen(parsed_issue_arg.patch_url).read() @@ -4316,6 +4317,9 @@ def CMDdiff(parser, args): # Create a new branch based on the merge-base RunGit(['checkout', '-q', '-b', TMP_BRANCH, base_branch]) + # Update the cached branch in cl instance, to avoid overwriting original + # branch properties. + cl.branch = cl.branchref = None try: rtn = cl.CMDPatchIssue(issue, reject=False, nocommit=False, directory=None) if rtn != 0: