diff options
| author | Ficus Kirkpatrick <ficus@android.com> | 2009-05-04 12:45:11 -0700 |
|---|---|---|
| committer | Shawn O. Pearce <sop@google.com> | 2009-05-05 15:01:18 -0700 |
| commit | bc7ef67d9bfcebe17c89eb57cb465d0d6d1d999d (patch) | |
| tree | f5cb5e47c6d5ad8bc2ebfdcdef55df77f62349a9 /subcmds/upload.py | |
| parent | 2f968c943b1c6f61f867fa9b87105836e0e5f354 (diff) | |
| download | git-repo-bc7ef67d9bfcebe17c89eb57cb465d0d6d1d999d.tar.gz | |
Automatically guess Gerrit change number in "repo upload --replace"v1.6.7.4
This feature only works if you have one commit to replace right now
(the common case).
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.') |
