mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
git-mfc: Cherry-pick all commits in one git command
This allows one to resume from a conflict with a plain `git cherry-pick --continue`, whereas before one would have to re-run the original git-mfc command after resolving the conflict and running `git cherry-pick --continue`. Suggested by: des Reviewed by: des Differential Revision: https://reviews.freebsd.org/D58129
This commit is contained in:
1 parent
1f091ad283
commit
59a4b6c2a0
2 files changed
+16
-11
No files matched your search
@@ -360,17 +360,16 @@ def pending(repo, upstream, author=None, committer=None, baking=False):
|
||||
return list(results.values())
|
||||
|
||||
|
||||
def cherry_pick(commit, edit=False):
|
||||
"""Cherry-pick a single commit with -x. Abort on failure."""
|
||||
def cherry_pick(commits, edit=False):
|
||||
"""Cherry-pick a list of commits with -x. Abort on failure."""
|
||||
cmd = ['git', 'cherry-pick', '-x', '-m1']
|
||||
if edit:
|
||||
cmd.append('-e')
|
||||
cmd.append(commit.hexsha)
|
||||
cmd.extend([c.hexsha for c in commits])
|
||||
result = subprocess.run(cmd, capture_output=False)
|
||||
if result.returncode != 0:
|
||||
print(f"\nCherry-pick of {commit.hexsha} ({commit.summary}) failed.",
|
||||
file=sys.stderr)
|
||||
print("Resolve the conflict and then re-run git mfc to continue,",
|
||||
print("\nCherry-pick failed.", file=sys.stderr)
|
||||
print("Resolve the conflict and run 'git cherry-pick --continue',",
|
||||
file=sys.stderr)
|
||||
print("or run 'git cherry-pick --abort' to give up.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
@@ -521,13 +520,16 @@ def main():
|
||||
print(commit.hexsha, commit.summary)
|
||||
return
|
||||
|
||||
topick = []
|
||||
for commit in tomfc:
|
||||
if commit.hexsha in already_picked:
|
||||
print(f"Skipping {commit.hexsha[:12]} {commit.summary} "
|
||||
f"(already cherry-picked)")
|
||||
continue
|
||||
print(f"Cherry-picking {commit.hexsha[:12]} {commit.summary}")
|
||||
cherry_pick(commit, edit=args.edit)
|
||||
topick.append(commit)
|
||||
if topick:
|
||||
cherry_pick(topick, edit=args.edit)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -68,13 +68,16 @@ Fixup commits that have been reverted are skipped with a warning.
|
||||
.Pp
|
||||
Commits that have already been cherry-picked to the current branch are
|
||||
automatically skipped.
|
||||
This allows the same
|
||||
.Nm
|
||||
command to be re-run after resolving a conflict without re-applying
|
||||
earlier commits.
|
||||
Use
|
||||
.Fl f
|
||||
to override this behavior.
|
||||
.Pp
|
||||
All commits are cherry-picked using a single
|
||||
.Xr git-cherry-pick 1
|
||||
invocation.
|
||||
If a conflict occurs, resolve it and run
|
||||
.Dq git cherry-pick --continue
|
||||
to proceed with the remaining commits.
|
||||
.It
|
||||
In
|
||||
.Fl -pending
|
||||
|
||||
Reference in new issue
Block a user