summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--project.py6
-rw-r--r--subcmds/upload.py78
2 files changed, 1 insertions, 83 deletions
diff --git a/project.py b/project.py
index ce85b863..01dc8678 100644
--- a/project.py
+++ b/project.py
@@ -111,7 +111,6 @@ class ReviewableBranch(object):
111 self.project = project 111 self.project = project
112 self.branch = branch 112 self.branch = branch
113 self.base = base 113 self.base = base
114 self.replace_changes = None
115 114
116 @property 115 @property
117 def name(self): 116 def name(self):
@@ -151,7 +150,6 @@ class ReviewableBranch(object):
151 150
152 def UploadForReview(self, people, auto_topic=False): 151 def UploadForReview(self, people, auto_topic=False):
153 self.project.UploadForReview(self.name, 152 self.project.UploadForReview(self.name,
154 self.replace_changes,
155 people, 153 people,
156 auto_topic=auto_topic) 154 auto_topic=auto_topic)
157 155
@@ -557,7 +555,6 @@ class Project(object):
557 return None 555 return None
558 556
559 def UploadForReview(self, branch=None, 557 def UploadForReview(self, branch=None,
560 replace_changes=None,
561 people=([],[]), 558 people=([],[]),
562 auto_topic=False): 559 auto_topic=False):
563 """Uploads the named branch for code review. 560 """Uploads the named branch for code review.
@@ -600,9 +597,6 @@ class Project(object):
600 cmd.append(branch.remote.SshReviewUrl(self.UserEmail)) 597 cmd.append(branch.remote.SshReviewUrl(self.UserEmail))
601 cmd.append(ref_spec) 598 cmd.append(ref_spec)
602 599
603 if replace_changes:
604 for change_id,commit_id in replace_changes.iteritems():
605 cmd.append('%s:refs/changes/%s/new' % (commit_id, change_id))
606 if GitCommand(self, cmd, bare = True).Wait() != 0: 600 if GitCommand(self, cmd, bare = True).Wait() != 0:
607 raise UploadError('Upload failed') 601 raise UploadError('Upload failed')
608 602
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: