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 --- gerrit_upload.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gerrit_upload.py') diff --git a/gerrit_upload.py b/gerrit_upload.py index f8dccdc5..32451408 100755 --- a/gerrit_upload.py +++ b/gerrit_upload.py @@ -75,6 +75,7 @@ def UploadBundle(project, dest_branch, src_branch, bases, + replace_changes = None, save_cookies=True): srv = _GetRpcServer(email, server, save_cookies) @@ -113,6 +114,10 @@ def UploadBundle(project, req.dest_branch = str(dest_branch) for c in revlist: req.contained_object.append(c) + for change_id,commit_id in replace_changes.iteritems(): + r = req.replace.add() + r.change_id = change_id + r.object_id = commit_id else: req = UploadBundleContinue() req.bundle_id = bundle_id @@ -148,6 +153,10 @@ def UploadBundle(project, elif rsp.status_code == UploadBundleResponse.UNAUTHORIZED_USER: reason = ('Unauthorized user. Visit http://%s/hello to sign up.' % server) + elif rsp.status_code == UploadBundleResponse.UNKNOWN_CHANGE: + reason = 'invalid change id' + elif rsp.status_code == UploadBundleResponse.CHANGE_CLOSED: + reason = 'one or more changes are closed' else: reason = 'unknown error ' + str(rsp.status_code) raise UploadError(reason) -- cgit v1.2.3-54-g00ecf