Index: git_cl.py |
diff --git a/git_cl.py b/git_cl.py |
index 2d915b0b7f3a67db26a06344e23a4ba25c8320c8..d0adcac7fe3f39e6a2af4626525c6fdcfecfcc30 100755 |
--- a/git_cl.py |
+++ b/git_cl.py |
@@ -2945,15 +2945,41 @@ 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.") |
iannucci
2016/01/30 02:54:20
I would add some warning text here: "CAUTION: This
Mircea Trofin
2016/02/02 00:35:49
Done.
|
+ 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.print_help() |
iannucci
2016/01/30 02:54:20
maybe want to try
parser.error("--reapply implies
Dirk Pranke
2016/02/01 23:19:19
nit: s/if len(args) > 0:/if args:/
Mircea Trofin
2016/02/02 00:35:49
Done.
Mircea Trofin
2016/02/02 00:35:49
I saw len(args) elsewhere. For consistency, I'd pr
|
+ return 1 |
+ |
+ cl = Changelist() |
+ issue_arg = cl.GetIssue() |
+ upstream = cl.GetUpstreamBranch() |
+ RunGit(['reset', '--hard', upstream]) |
iannucci
2016/01/30 02:54:21
you may need to check for None here. Some folks (s
Mircea Trofin
2016/02/02 00:35:49
Actually, that'll set the branch to master, but I
|
+ if options.pull: |
+ RunGit(['pull']) |
+ else: |
+ if len(args) != 1: |
+ parser.print_help() |
+ return 1 |
iannucci
2016/01/30 02:54:21
same here and below re: parser.error
Mircea Trofin
2016/02/02 00:35:49
Done.
|
+ 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 +2994,9 @@ def CMDpatch(parser, args): |
# TODO(ukai): use gerrit-cherry-pick for gerrit repository? |
if options.newbranch: |
+ if options.reapply: |
+ parser.print_help() |
+ return 1 |
if options.force: |
RunGit(['branch', '-D', options.newbranch], |
stderr=subprocess2.PIPE, error_ok=True) |