summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2020-03-22 12:15:20 -0400
committerMike Frysinger <vapier@google.com>2020-03-23 00:27:52 +0000
commit915fda130efa14b9314b500d122f9af707518508 (patch)
tree054e7a0322bbd7927cfe57792dea28f6e855839c
parentea43176de0a46eadb12be814517532a13eec8b1d (diff)
downloadgit-repo-915fda130efa14b9314b500d122f9af707518508.tar.gz
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>
-rw-r--r--project.py4
-rw-r--r--subcmds/download.py13
2 files changed, 15 insertions, 2 deletions
diff --git a/project.py b/project.py
index a58af4ff..d35ad52d 100644
--- a/project.py
+++ b/project.py
@@ -2681,10 +2681,12 @@ class Project(object):
2681 if self._allrefs: 2681 if self._allrefs:
2682 raise GitError('%s checkout %s ' % (self.name, rev)) 2682 raise GitError('%s checkout %s ' % (self.name, rev))
2683 2683
2684 def _CherryPick(self, rev, ffonly=False): 2684 def _CherryPick(self, rev, ffonly=False, record_origin=False):
2685 cmd = ['cherry-pick'] 2685 cmd = ['cherry-pick']
2686 if ffonly: 2686 if ffonly:
2687 cmd.append('--ff') 2687 cmd.append('--ff')
2688 if record_origin:
2689 cmd.append('-x')
2688 cmd.append(rev) 2690 cmd.append(rev)
2689 cmd.append('--') 2691 cmd.append('--')
2690 if GitCommand(self, cmd).Wait() != 0: 2692 if GitCommand(self, cmd).Wait() != 0:
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.
40 p.add_option('-c', '--cherry-pick', 40 p.add_option('-c', '--cherry-pick',
41 dest='cherrypick', action='store_true', 41 dest='cherrypick', action='store_true',
42 help="cherry-pick instead of checkout") 42 help="cherry-pick instead of checkout")
43 p.add_option('-x', '--record-origin', action='store_true',
44 help='pass -x when cherry-picking')
43 p.add_option('-r', '--revert', 45 p.add_option('-r', '--revert',
44 dest='revert', action='store_true', 46 dest='revert', action='store_true',
45 help="revert instead of checkout") 47 help="revert instead of checkout")
@@ -78,6 +80,14 @@ If no project is specified try to use current directory as a project.
78 project = self.GetProjects([a])[0] 80 project = self.GetProjects([a])[0]
79 return to_get 81 return to_get
80 82
83 def ValidateOptions(self, opt, args):
84 if opt.record_origin:
85 if not opt.cherrypick:
86 self.OptionParser.error('-x only makes sense with --cherry-pick')
87
88 if opt.ffonly:
89 self.OptionParser.error('-x and --ff are mutually exclusive options')
90
81 def Execute(self, opt, args): 91 def Execute(self, opt, args):
82 for project, change_id, ps_id in self._ParseChangeIds(args): 92 for project, change_id, ps_id in self._ParseChangeIds(args):
83 dl = project.DownloadPatchSet(change_id, ps_id) 93 dl = project.DownloadPatchSet(change_id, ps_id)
@@ -101,7 +111,8 @@ If no project is specified try to use current directory as a project.
101 print(' %s' % (c), file=sys.stderr) 111 print(' %s' % (c), file=sys.stderr)
102 if opt.cherrypick: 112 if opt.cherrypick:
103 try: 113 try:
104 project._CherryPick(dl.commit, ffonly=opt.ffonly) 114 project._CherryPick(dl.commit, ffonly=opt.ffonly,
115 record_origin=opt.record_origin)
105 except GitError: 116 except GitError:
106 print('[%s] Could not complete the cherry-pick of %s' 117 print('[%s] Could not complete the cherry-pick of %s'
107 % (project.name, dl.commit), file=sys.stderr) 118 % (project.name, dl.commit), file=sys.stderr)