| Index: git_cl.py
|
| diff --git a/git_cl.py b/git_cl.py
|
| index 35785ebdf0443e4c86784f4c820b0a7c71ca9103..241e203153a6bb12bd6c08531936b03e99bcdcf3 100755
|
| --- a/git_cl.py
|
| +++ b/git_cl.py
|
| @@ -4092,14 +4092,18 @@ def CMDpatch(parser, args):
|
| _process_codereview_select_options(parser, options)
|
| auth_config = auth.extract_auth_config_from_options(options)
|
|
|
| - cl = Changelist(auth_config=auth_config, codereview=options.forced_codereview)
|
|
|
| - issue_arg = None
|
| if options.reapply :
|
| + if options.newbranch:
|
| + parser.error('--reapply works on the current branch only')
|
| if len(args) > 0:
|
| - parser.error('--reapply implies no additional arguments.')
|
| + parser.error('--reapply implies no additional arguments')
|
| +
|
| + cl = Changelist(auth_config=auth_config,
|
| + codereview=options.forced_codereview)
|
| + if not cl.GetIssue():
|
| + parser.error('current branch must have an associated issue')
|
|
|
| - issue_arg = cl.GetIssue()
|
| upstream = cl.GetUpstreamBranch()
|
| if upstream == None:
|
| parser.error('No upstream branch specified. Cannot reset branch')
|
| @@ -4107,37 +4111,34 @@ def CMDpatch(parser, args):
|
| RunGit(['reset', '--hard', upstream])
|
| if options.pull:
|
| RunGit(['pull'])
|
| - else:
|
| - if len(args) != 1:
|
| - parser.error('Must specify issue number or url')
|
| - issue_arg = args[0]
|
|
|
| - if not issue_arg:
|
| - parser.print_help()
|
| - return 1
|
| + return cl.CMDPatchIssue(cl.GetIssue(), options.reject, options.nocommit,
|
| + options.directory)
|
|
|
| - if cl.IsGerrit():
|
| - if options.reject:
|
| - parser.error('--reject is not supported with Gerrit codereview.')
|
| - if options.nocommit:
|
| - parser.error('--nocommit is not supported with Gerrit codereview.')
|
| - if options.directory:
|
| - parser.error('--directory is not supported with Gerrit codereview.')
|
| + if len(args) != 1 or not args[0]:
|
| + parser.error('Must specify issue number or url')
|
|
|
| # We don't want uncommitted changes mixed up with the patch.
|
| if git_common.is_dirty_git_tree('patch'):
|
| return 1
|
|
|
| if options.newbranch:
|
| - if options.reapply:
|
| - parser.error("--reapply excludes any option other than --pull")
|
| if options.force:
|
| RunGit(['branch', '-D', options.newbranch],
|
| - stderr=subprocess2.PIPE, error_ok=True)
|
| - RunGit(['checkout', '-b', options.newbranch,
|
| - Changelist().GetUpstreamBranch()])
|
| + stderr=subprocess2.PIPE, error_ok=True)
|
| + RunGit(['new-branch', options.newbranch])
|
| +
|
| + cl = Changelist(auth_config=auth_config, codereview=options.forced_codereview)
|
| +
|
| + if cl.IsGerrit():
|
| + if options.reject:
|
| + parser.error('--reject is not supported with Gerrit codereview.')
|
| + if options.nocommit:
|
| + parser.error('--nocommit is not supported with Gerrit codereview.')
|
| + if options.directory:
|
| + parser.error('--directory is not supported with Gerrit codereview.')
|
|
|
| - return cl.CMDPatchIssue(issue_arg, options.reject, options.nocommit,
|
| + return cl.CMDPatchIssue(args[0], options.reject, options.nocommit,
|
| options.directory)
|
|
|
|
|
|
|