From 915fda130efa14b9314b500d122f9af707518508 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 22 Mar 2020 12:15:20 -0400 Subject: download: support -x when cherry-picking This is a pretty common option for people to want too use, so include it as a pass-thru option when cherry-picking. Bug: https://crbug.com/gerrit/9418 Change-Id: I2a24c1ed7544541719caa4d3c0574347a151a1b0 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/259853 Reviewed-by: David Pursehouse Tested-by: Mike Frysinger --- subcmds/download.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'subcmds/download.py') diff --git a/subcmds/download.py b/subcmds/download.py index 12d99526..db9595a2 100644 --- a/subcmds/download.py +++ b/subcmds/download.py @@ -40,6 +40,8 @@ If no project is specified try to use current directory as a project. p.add_option('-c', '--cherry-pick', dest='cherrypick', action='store_true', help="cherry-pick instead of checkout") + p.add_option('-x', '--record-origin', action='store_true', + help='pass -x when cherry-picking') p.add_option('-r', '--revert', dest='revert', action='store_true', help="revert instead of checkout") @@ -78,6 +80,14 @@ If no project is specified try to use current directory as a project. project = self.GetProjects([a])[0] return to_get + def ValidateOptions(self, opt, args): + if opt.record_origin: + if not opt.cherrypick: + self.OptionParser.error('-x only makes sense with --cherry-pick') + + if opt.ffonly: + self.OptionParser.error('-x and --ff are mutually exclusive options') + def Execute(self, opt, args): for project, change_id, ps_id in self._ParseChangeIds(args): dl = project.DownloadPatchSet(change_id, ps_id) @@ -101,7 +111,8 @@ If no project is specified try to use current directory as a project. print(' %s' % (c), file=sys.stderr) if opt.cherrypick: try: - project._CherryPick(dl.commit, ffonly=opt.ffonly) + project._CherryPick(dl.commit, ffonly=opt.ffonly, + record_origin=opt.record_origin) except GitError: print('[%s] Could not complete the cherry-pick of %s' % (project.name, dl.commit), file=sys.stderr) -- cgit v1.2.3-54-g00ecf