From d85c1b1cb202ed168dcf12de8896061f6c00a86b Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Tue, 6 Feb 2024 16:14:31 +0000 Subject: [PATCH 1/2] tools/batch-rebase: Support Path in json dump FIX --- tools/batch-rebase/src/batch_rebase/main.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/batch-rebase/src/batch_rebase/main.py b/tools/batch-rebase/src/batch_rebase/main.py index 0095660bc..65759fa65 100755 --- a/tools/batch-rebase/src/batch_rebase/main.py +++ b/tools/batch-rebase/src/batch_rebase/main.py @@ -22,7 +22,7 @@ import shlex import argparse import subprocess import sys -from collections.abc import Mapping +from collections.abc import Mapping, Iterable from collections import Counter import tempfile from pathlib import Path @@ -86,7 +86,21 @@ def load_conf(path): def dump_conf(conf, path): + def convert(value): + if isinstance(value, Mapping): + return { + convert(k): convert(v) + for k, v in value.items() + } + elif isinstance(value, (str, Path)): + return str(value) + elif isinstance(value, Iterable): + return [convert(x) for x in value] + else: + return value + conf = {'rebase-conf': conf} + conf = convert(conf) with open(path, 'w') as f: json.dump(conf, f) -- GitLab From 66db9ea76c827ff32259dc0c273ea18e31b9b20d Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Tue, 6 Feb 2024 16:17:12 +0000 Subject: [PATCH 2/2] tools/batch-rebase: Cherry pick commits in correct order FIX --- tools/batch-rebase/src/batch_rebase/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/batch-rebase/src/batch_rebase/main.py b/tools/batch-rebase/src/batch_rebase/main.py index 65759fa65..ceef0d0c6 100755 --- a/tools/batch-rebase/src/batch_rebase/main.py +++ b/tools/batch-rebase/src/batch_rebase/main.py @@ -379,7 +379,7 @@ def _do_cherry_pick(repo, conf, persistent_tags, tags_suffix): range_base = f'refs/remotes/{remote}/{base}' range_tip = f'refs/remotes/{remote}/{tip}' range_ref = f'{range_base}..{range_tip}' - range_sha1s = git(['rev-list', range_ref], capture=True).splitlines() + range_sha1s = list(reversed(git(['rev-list', range_ref], capture=True).splitlines())) nr_commits = len(range_sha1s) info('Cherry-picking topic "{name}" from {remote} ({nr_commits} commits)\nremote: {remote}\nbase: {base}\ntip: {tip}\n'.format( -- GitLab