mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
git cl cherry-pick: Use base parameter to fix identical tree errors
The `git cl cherry-pick` command previously created chained CLs by
first cherry-picking a change onto the destination branch tip and then
rebasing the result onto the parent CL created in the previous step.
This approach failed when a sequence of cherry-picks resulted in an
intermediate state having an identical tree compared to its intended
base (e.g., commit 1 changes X->Y, commit 2 changes Y->X). Gerrit
would reject the second cherry-pick with an "identical tree" error
because the rebase is done after the cherry pick.
This change modifies the process to use the `base` parameter of the
Gerrit `cherrypick` REST API endpoint.
Changes:
- Modify `gerrit_util.CherryPick` to accept and pass an optional `base`
commit hash in the API request body.
- Update `git_cl.CMDcherry_pick`:
- Before each cherry-pick operation in the loop, fetch the commit hash
of the latest patchset from the previously processed parent CL.
- Pass this commit hash as the `base` parameter to `gerrit_util.CherryPick`.
- Remove the subsequent, now redundant, call to `gerrit_util.RebaseChange`.
This ensures the correct parent commit is specified during the
cherry-pick operation itself, allowing Gerrit to handle the chaining
correctly and avoid failures caused by identical tree states in
intermediate steps.
Bug: 408388488
Change-Id: I84066d65bd6bb127b253bee6564dd0622148a0e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6433112
Commit-Queue: Gennady Tsitovich <gtsitovich@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
This commit is contained in:
committed by
LUCI CQ
parent
36bfafbc82
commit
6cc266569e
@@ -1518,7 +1518,12 @@ def DeletePendingChangeEdit(host, change):
|
||||
ReadHttpResponse(conn, accept_statuses=[204, 404])
|
||||
|
||||
|
||||
def CherryPick(host, change, destination, revision='current', message=None):
|
||||
def CherryPick(host,
|
||||
change,
|
||||
destination,
|
||||
revision='current',
|
||||
message=None,
|
||||
base=None):
|
||||
"""Create a cherry-pick commit from the given change, onto the given
|
||||
destination.
|
||||
"""
|
||||
@@ -1526,6 +1531,8 @@ def CherryPick(host, change, destination, revision='current', message=None):
|
||||
body = {'destination': destination}
|
||||
if message:
|
||||
body['message'] = message
|
||||
if base:
|
||||
body['base'] = base
|
||||
conn = CreateHttpConn(host, path, reqtype='POST', body=body)
|
||||
|
||||
# If a cherry pick fails due to a merge conflict, Gerrit returns 409.
|
||||
|
||||
Reference in New Issue
Block a user