diff --git a/git_cl.py b/git_cl.py index d54b46c27..9b943d26c 100755 --- a/git_cl.py +++ b/git_cl.py @@ -2006,7 +2006,8 @@ class Changelist(object): break return 0 - def CMDPatchWithParsedIssue(self, parsed_issue_arg, nocommit, force): + def CMDPatchWithParsedIssue(self, parsed_issue_arg, nocommit, force, + newbranch): assert parsed_issue_arg.valid self.issue = parsed_issue_arg.issue @@ -2047,6 +2048,11 @@ class Changelist(object): RunGit(['fetch', fetch_info['url'], fetch_info['ref']]) + # If we have created a new branch then do the "set issue" immediately in + # case the cherry-pick fails, which happens when resolving conflicts. + if newbranch: + self.SetIssue(parsed_issue_arg.issue) + if force: RunGit(['reset', '--hard', 'FETCH_HEAD']) print('Checked out commit for change %i patchset %i locally' % @@ -4390,7 +4396,8 @@ def CMDpatch(parser, args): RunGit(['pull']) target_issue_arg = ParseIssueNumberArgument(cl.GetIssue()) - return cl.CMDPatchWithParsedIssue(target_issue_arg, options.nocommit, False) + return cl.CMDPatchWithParsedIssue(target_issue_arg, options.nocommit, False, + False) if len(args) != 1 or not args[0]: parser.error('Must specify issue number or URL.') @@ -4415,8 +4422,8 @@ def CMDpatch(parser, args): if not args[0].isdigit(): print('canonical issue/change URL: %s\n' % cl.GetIssueURL()) - return cl.CMDPatchWithParsedIssue( - target_issue_arg, options.nocommit, options.force) + return cl.CMDPatchWithParsedIssue(target_issue_arg, options.nocommit, + options.force, options.newbranch) def GetTreeStatus(url=None):