Teach 'repo upload --replace' how to add replacement patch sets

Users are prompted with the list of known changes we are about
to upload, and they can fill out the current change numbers for
any changes which already exist in the data store.  For each of
those changes the change number and commit id is sent as part of
the upload request, so Gerrit can insert the new commit as a new
patch set of the existing change, rather than make a new change.

This facility permits developers to replace a patch so they can
address comments made on a prior version of the same change.

Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2008-11-11 17:12:43 -08:00
parent ec18b4bac4
commit c99883fee9
3 changed files with 83 additions and 4 deletions

View File

@ -104,6 +104,7 @@ class ReviewableBranch(object):
self.project = project
self.branch = branch
self.base = base
self.replace_changes = None
@property
def name(self):
@ -123,6 +124,16 @@ class ReviewableBranch(object):
'--')
return self._commit_cache
@property
def unabbrev_commits(self):
r = dict()
for commit in self.project.bare_git.rev_list(
not_rev(self.base),
R_HEADS + self.name,
'--'):
r[commit[0:8]] = commit
return r
@property
def date(self):
return self.project.bare_git.log(
@ -132,7 +143,8 @@ class ReviewableBranch(object):
'--')
def UploadForReview(self):
self.project.UploadForReview(self.name)
self.project.UploadForReview(self.name,
self.replace_changes)
@property
def tip_url(self):
@ -444,7 +456,7 @@ class Project(object):
return rb
return None
def UploadForReview(self, branch=None):
def UploadForReview(self, branch=None, replace_changes=None):
"""Uploads the named branch for code review.
"""
if branch is None:
@ -482,7 +494,8 @@ class Project(object):
dest_project = branch.remote.projectname,
dest_branch = dest_branch,
src_branch = R_HEADS + branch.name,
bases = base_list)
bases = base_list,
replace_changes = replace_changes)
except proto_client.ClientLoginError:
raise UploadError('Login failure')
except urllib2.HTTPError, e: