From c99883fee990a1baa7e0bf5f854c7485b7d0f0d9 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 11 Nov 2008 17:12:43 -0800 Subject: 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 --- project.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'project.py') diff --git a/project.py b/project.py index 1e25c2c9..39550335 100644 --- a/project.py +++ b/project.py @@ -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: -- cgit v1.2.3-54-g00ecf