mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
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 <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
parent
ea43176de0
commit
915fda130e
@ -2681,10 +2681,12 @@ class Project(object):
|
||||
if self._allrefs:
|
||||
raise GitError('%s checkout %s ' % (self.name, rev))
|
||||
|
||||
def _CherryPick(self, rev, ffonly=False):
|
||||
def _CherryPick(self, rev, ffonly=False, record_origin=False):
|
||||
cmd = ['cherry-pick']
|
||||
if ffonly:
|
||||
cmd.append('--ff')
|
||||
if record_origin:
|
||||
cmd.append('-x')
|
||||
cmd.append(rev)
|
||||
cmd.append('--')
|
||||
if GitCommand(self, cmd).Wait() != 0:
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user