diff options
-rw-r--r-- | project.py | 4 | ||||
-rw-r--r-- | subcmds/download.py | 13 |
2 files changed, 15 insertions, 2 deletions
@@ -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) |