repo download: add --cherry-pick option

default option uses git checkout, and thus overwrite the previous
checkouts.  this is a problem for automated builds of several
changesets in the same project for daily builds of pending submission

You can now use:
repo download [--cherry-pick|-c] project changeid/patchnumber

This will parse the manifest, cd to the corresponding project
download the changes to FETCH_HEAD and cherry-pick the result.

This is useful to automate cherry-picking of a patch
in the context of build automation, and commit gating (e.g. buildbot)

Change-Id: Ib638afd87677f1be197afb7b0f73c70fb98909fe
Signed-off-by: Pierre Tardy <pierre.tardy@intel.com>
This commit is contained in:
Pierre Tardy 2011-03-24 16:28:18 +01:00 committed by Shawn O. Pearce
parent ccf86432b3
commit e5a2122e64
2 changed files with 15 additions and 2 deletions

View File

@ -1637,6 +1637,14 @@ class Project(object):
if self._allrefs: if self._allrefs:
raise GitError('%s checkout %s ' % (self.name, rev)) raise GitError('%s checkout %s ' % (self.name, rev))
def _CherryPick(self, rev, quiet=False):
cmd = ['cherry-pick']
cmd.append(rev)
cmd.append('--')
if GitCommand(self, cmd).Wait() != 0:
if self._allrefs:
raise GitError('%s cherry-pick %s ' % (self.name, rev))
def _ResetHard(self, rev, quiet=True): def _ResetHard(self, rev, quiet=True):
cmd = ['reset', '--hard'] cmd = ['reset', '--hard']
if quiet: if quiet:

View File

@ -33,7 +33,9 @@ makes it available in your project's local working directory.
""" """
def _Options(self, p): def _Options(self, p):
pass p.add_option('-c','--cherry-pick',
dest='cherrypick', action='store_true',
help="cherry-pick instead of checkout")
def _ParseChangeIds(self, args): def _ParseChangeIds(self, args):
if not args: if not args:
@ -78,4 +80,7 @@ makes it available in your project's local working directory.
% (project.name, change_id, ps_id, len(dl.commits)) % (project.name, change_id, ps_id, len(dl.commits))
for c in dl.commits: for c in dl.commits:
print >>sys.stderr, ' %s' % (c) print >>sys.stderr, ' %s' % (c)
if opt.cherrypick:
project._CherryPick(dl.commit)
else:
project._Checkout(dl.commit) project._Checkout(dl.commit)