diff options
Diffstat (limited to 'subcmds/upload.py')
-rw-r--r-- | subcmds/upload.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/subcmds/upload.py b/subcmds/upload.py index aea399b6..4dc11d28 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py | |||
@@ -20,6 +20,17 @@ from command import InteractiveCommand | |||
20 | from editor import Editor | 20 | from editor import Editor |
21 | from error import UploadError | 21 | from error import UploadError |
22 | 22 | ||
23 | UNUSUAL_COMMIT_THRESHOLD = 3 | ||
24 | |||
25 | def _ConfirmManyUploads(multiple_branches=False): | ||
26 | if multiple_branches: | ||
27 | print "ATTENTION: One or more branches has an unusually high number of commits." | ||
28 | else: | ||
29 | print "ATTENTION: You are uploading an unusually high number of commits." | ||
30 | print "YOU PROBABLY DO NOT MEAN TO DO THIS. (Did you rebase across branches?)" | ||
31 | answer = raw_input("If you are sure you intend to do this, type 'yes': ").strip() | ||
32 | return answer == "yes" | ||
33 | |||
23 | def _die(fmt, *args): | 34 | def _die(fmt, *args): |
24 | msg = fmt % args | 35 | msg = fmt % args |
25 | print >>sys.stderr, 'error: %s' % msg | 36 | print >>sys.stderr, 'error: %s' % msg |
@@ -129,6 +140,10 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
129 | answer = answer in ('y', 'Y', 'yes', '1', 'true', 't') | 140 | answer = answer in ('y', 'Y', 'yes', '1', 'true', 't') |
130 | 141 | ||
131 | if answer: | 142 | if answer: |
143 | if len(branch.commits) > UNUSUAL_COMMIT_THRESHOLD: | ||
144 | answer = _ConfirmManyUploads() | ||
145 | |||
146 | if answer: | ||
132 | self._UploadAndReport([branch], people) | 147 | self._UploadAndReport([branch], people) |
133 | else: | 148 | else: |
134 | _die("upload aborted by user") | 149 | _die("upload aborted by user") |
@@ -192,6 +207,16 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
192 | todo.append(branch) | 207 | todo.append(branch) |
193 | if not todo: | 208 | if not todo: |
194 | _die("nothing uncommented for upload") | 209 | _die("nothing uncommented for upload") |
210 | |||
211 | many_commits = False | ||
212 | for branch in todo: | ||
213 | if len(branch.commits) > UNUSUAL_COMMIT_THRESHOLD: | ||
214 | many_commits = True | ||
215 | break | ||
216 | if many_commits: | ||
217 | if not _ConfirmManyUploads(multiple_branches=True): | ||
218 | _die("upload aborted by user") | ||
219 | |||
195 | self._UploadAndReport(todo, people) | 220 | self._UploadAndReport(todo, people) |
196 | 221 | ||
197 | def _FindGerritChange(self, branch): | 222 | def _FindGerritChange(self, branch): |
@@ -258,6 +283,10 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
258 | print >>sys.stderr, " use 'repo upload' without --replace" | 283 | print >>sys.stderr, " use 'repo upload' without --replace" |
259 | sys.exit(1) | 284 | sys.exit(1) |
260 | 285 | ||
286 | if len(branch.commits) > UNUSUAL_COMMIT_THRESHOLD: | ||
287 | if not _ConfirmManyUploads(multiple_branches=True): | ||
288 | _die("upload aborted by user") | ||
289 | |||
261 | branch.replace_changes = to_replace | 290 | branch.replace_changes = to_replace |
262 | self._UploadAndReport([branch], people) | 291 | self._UploadAndReport([branch], people) |
263 | 292 | ||