Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(457)

Unified Diff: git_cl.py

Issue 2022183003: Fix & refactor git cl patch. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698