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

Unified Diff: git_cl.py

Issue 1641903002: Use current issue number for git cl patch (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 4 years, 11 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 | no next file » | 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 2d915b0b7f3a67db26a06344e23a4ba25c8320c8..6439e1be7e239fb2ac687e8c1abd6e0e9b78bee3 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -2945,15 +2945,45 @@ def CMDpatch(parser, args):
'attempting a 3-way merge')
parser.add_option('-n', '--no-commit', action='store_true', dest='nocommit',
help="don't commit after patch applies")
+
+ group = optparse.OptionGroup(parser,
+ """Options for continuing work on the current issue uploaded
+from a different clone (e.g. different machine). Must be used independently from
+the other options. No issue number should be specified, and the branch must have
+an issue number associated with it""")
+ group.add_option('--reapply', action='store_true',
+ dest='reapply',
+ help="""Reset the branch and reapply the issue.
+CAUTION: This will undo any local changes in this branch""")
+
+ group.add_option('--pull', action='store_true', dest='pull',
+ help="Performs a pull before reapplying.")
+ parser.add_option_group(group)
+
auth.add_auth_options(parser)
(options, args) = parser.parse_args(args)
auth_config = auth.extract_auth_config_from_options(options)
- if len(args) != 1:
- parser.print_help()
- return 1
+ issue_arg = None
+ if options.reapply :
+ if len(args) > 0:
+ parser.error("--reapply implies no additional arguments.")
+
+ cl = Changelist()
+ issue_arg = cl.GetIssue()
+ upstream = cl.GetUpstreamBranch()
+ if upstream == None:
+ parser.error("No upstream branch specified. Cannot reset branch")
+
+ RunGit(['reset', '--hard', upstream])
+ if options.pull:
+ RunGit(['pull'])
+ else:
+ if len(args) != 1:
+ parser.error("Must specify issue number")
+
+ issue_arg = ParseIssueNum(args[0])
- issue_arg = ParseIssueNum(args[0])
# The patch URL works because ParseIssueNum won't do any substitution
# as the re.sub pattern fails to match and just returns it.
if issue_arg == None:
@@ -2968,6 +2998,8 @@ def CMDpatch(parser, args):
# TODO(ukai): use gerrit-cherry-pick for gerrit repository?
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)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698