diff options
Diffstat (limited to 'subcmds/upload.py')
| -rw-r--r-- | subcmds/upload.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/subcmds/upload.py b/subcmds/upload.py index 01ba4ad0..aea399b6 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py | |||
| @@ -194,6 +194,18 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
| 194 | _die("nothing uncommented for upload") | 194 | _die("nothing uncommented for upload") |
| 195 | self._UploadAndReport(todo, people) | 195 | self._UploadAndReport(todo, people) |
| 196 | 196 | ||
| 197 | def _FindGerritChange(self, branch): | ||
| 198 | last_pub = branch.project.WasPublished(branch.name) | ||
| 199 | if last_pub is None: | ||
| 200 | return "" | ||
| 201 | |||
| 202 | refs = branch.GetPublishedRefs() | ||
| 203 | try: | ||
| 204 | # refs/changes/XYZ/N --> XYZ | ||
| 205 | return refs.get(last_pub).split('/')[-2] | ||
| 206 | except: | ||
| 207 | return "" | ||
| 208 | |||
| 197 | def _ReplaceBranch(self, project, people): | 209 | def _ReplaceBranch(self, project, people): |
| 198 | branch = project.CurrentBranch | 210 | branch = project.CurrentBranch |
| 199 | if not branch: | 211 | if not branch: |
| @@ -206,8 +218,14 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
| 206 | 218 | ||
| 207 | script = [] | 219 | script = [] |
| 208 | script.append('# Replacing from branch %s' % branch.name) | 220 | script.append('# Replacing from branch %s' % branch.name) |
| 209 | for commit in branch.commits: | 221 | |
| 210 | script.append('[ ] %s' % commit) | 222 | if len(branch.commits) == 1: |
| 223 | change = self._FindGerritChange(branch) | ||
| 224 | script.append('[%-6s] %s' % (change, branch.commits[0])) | ||
| 225 | else: | ||
| 226 | for commit in branch.commits: | ||
| 227 | script.append('[ ] %s' % commit) | ||
| 228 | |||
| 211 | script.append('') | 229 | script.append('') |
| 212 | script.append('# Insert change numbers in the brackets to add a new patch set.') | 230 | script.append('# Insert change numbers in the brackets to add a new patch set.') |
| 213 | script.append('# To create a new change record, leave the brackets empty.') | 231 | script.append('# To create a new change record, leave the brackets empty.') |
