summaryrefslogtreecommitdiffstats
path: root/subcmds/upload.py
diff options
context:
space:
mode:
authorFicus Kirkpatrick <ficus@android.com>2010-10-22 13:06:47 -0700
committerShawn O. Pearce <sop@google.com>2010-10-29 12:12:56 -0700
commita0de6e8eab97f5dcdb2f51d4e09dd1568623ec58 (patch)
tree14a6939f997a33d04396627e1b032b812bfcec2d /subcmds/upload.py
parent16614f86b3cc8d61ccae7197624fa93fc752767b (diff)
downloadgit-repo-a0de6e8eab97f5dcdb2f51d4e09dd1568623ec58.tar.gz
upload: Remove --replace option
It hasn't been necessary for a long time, and its functionality can be accomplished with 'git push'. Change-Id: Ic00d3adbe4cee7be3955117489c69d6e90106559
Diffstat (limited to 'subcmds/upload.py')
-rw-r--r--subcmds/upload.py78
1 files changed, 1 insertions, 77 deletions
diff --git a/subcmds/upload.py b/subcmds/upload.py
index 153b3ebe..1964bffa 100644
--- a/subcmds/upload.py
+++ b/subcmds/upload.py
@@ -47,7 +47,7 @@ class Upload(InteractiveCommand):
47 common = True 47 common = True
48 helpSummary = "Upload changes for code review" 48 helpSummary = "Upload changes for code review"
49 helpUsage=""" 49 helpUsage="""
50%prog [--re --cc] {[<project>]... | --replace <project>} 50%prog [--re --cc] [<project>]...
51""" 51"""
52 helpDescription = """ 52 helpDescription = """
53The '%prog' command is used to send changes to the Gerrit Code 53The '%prog' command is used to send changes to the Gerrit Code
@@ -67,12 +67,6 @@ added to the respective list of users, and emails are sent to any
67new users. Users passed as --reviewers must already be registered 67new users. Users passed as --reviewers must already be registered
68with the code review system, or the upload will fail. 68with the code review system, or the upload will fail.
69 69
70If the --replace option is passed the user can designate which
71existing change(s) in Gerrit match up to the commits in the branch
72being uploaded. For each matched pair of change,commit the commit
73will be added as a new patch set, completely replacing the set of
74files and description associated with the change in Gerrit.
75
76Configuration 70Configuration
77------------- 71-------------
78 72
@@ -119,9 +113,6 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
119 p.add_option('-t', 113 p.add_option('-t',
120 dest='auto_topic', action='store_true', 114 dest='auto_topic', action='store_true',
121 help='Send local branch name to Gerrit Code Review') 115 help='Send local branch name to Gerrit Code Review')
122 p.add_option('--replace',
123 dest='replace', action='store_true',
124 help='Upload replacement patchesets from this branch')
125 p.add_option('--re', '--reviewers', 116 p.add_option('--re', '--reviewers',
126 type='string', action='append', dest='reviewers', 117 type='string', action='append', dest='reviewers',
127 help='Request reviews from these people.') 118 help='Request reviews from these people.')
@@ -262,65 +253,6 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
262 except: 253 except:
263 return "" 254 return ""
264 255
265 def _ReplaceBranch(self, opt, project, people):
266 branch = project.CurrentBranch
267 if not branch:
268 print >>sys.stdout, "no branches ready for upload"
269 return
270 branch = project.GetUploadableBranch(branch)
271 if not branch:
272 print >>sys.stdout, "no branches ready for upload"
273 return
274
275 script = []
276 script.append('# Replacing from branch %s' % branch.name)
277
278 if len(branch.commits) == 1:
279 change = self._FindGerritChange(branch)
280 script.append('[%-6s] %s' % (change, branch.commits[0]))
281 else:
282 for commit in branch.commits:
283 script.append('[ ] %s' % commit)
284
285 script.append('')
286 script.append('# Insert change numbers in the brackets to add a new patch set.')
287 script.append('# To create a new change record, leave the brackets empty.')
288
289 script = Editor.EditString("\n".join(script)).split("\n")
290
291 change_re = re.compile(r'^\[\s*(\d{1,})\s*\]\s*([0-9a-f]{1,}) .*$')
292 to_replace = dict()
293 full_hashes = branch.unabbrev_commits
294
295 for line in script:
296 m = change_re.match(line)
297 if m:
298 c = m.group(1)
299 f = m.group(2)
300 try:
301 f = full_hashes[f]
302 except KeyError:
303 print 'fh = %s' % full_hashes
304 print >>sys.stderr, "error: commit %s not found" % f
305 sys.exit(1)
306 if c in to_replace:
307 print >>sys.stderr,\
308 "error: change %s cannot accept multiple commits" % c
309 sys.exit(1)
310 to_replace[c] = f
311
312 if not to_replace:
313 print >>sys.stderr, "error: no replacements specified"
314 print >>sys.stderr, " use 'repo upload' without --replace"
315 sys.exit(1)
316
317 if len(branch.commits) > UNUSUAL_COMMIT_THRESHOLD:
318 if not _ConfirmManyUploads(multiple_branches=True):
319 _die("upload aborted by user")
320
321 branch.replace_changes = to_replace
322 self._UploadAndReport(opt, [branch], people)
323
324 def _UploadAndReport(self, opt, todo, original_people): 256 def _UploadAndReport(self, opt, todo, original_people):
325 have_errors = False 257 have_errors = False
326 for branch in todo: 258 for branch in todo:
@@ -383,14 +315,6 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
383 cc = _SplitEmails(opt.cc) 315 cc = _SplitEmails(opt.cc)
384 people = (reviewers,cc) 316 people = (reviewers,cc)
385 317
386 if opt.replace:
387 if len(project_list) != 1:
388 print >>sys.stderr, \
389 'error: --replace requires exactly one project'
390 sys.exit(1)
391 self._ReplaceBranch(opt, project_list[0], people)
392 return
393
394 for project in project_list: 318 for project in project_list:
395 avail = project.GetUploadableBranches() 319 avail = project.GetUploadableBranches()
396 if avail: 320 if avail: