From 963f2ff17c123aec2bd82482512b1fec5c18938d Mon Sep 17 00:00:00 2001 From: Damian Lokic Date: Mon, 27 Oct 2025 13:33:18 +0100 Subject: [PATCH 1/4] T289742: Extend zodbsync commands with zodbsync ff --- perfact/zodbsync/commands/fastforward.py | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 perfact/zodbsync/commands/fastforward.py diff --git a/perfact/zodbsync/commands/fastforward.py b/perfact/zodbsync/commands/fastforward.py new file mode 100644 index 0000000..8609f05 --- /dev/null +++ b/perfact/zodbsync/commands/fastforward.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +from ..subcommand import SubCommand + + +class FF(SubCommand): + '''Perform a fast-forward merge to the target commit and apply changed paths''' + @staticmethod + def add_args(parser): + parser.add_argument( + '--skip-errors', action='store_true', default=False, + help='Skip failed objects and continue', + ) + parser.add_argument( + '--dry-run', action='store_true', default=False, + help='Only check for conflicts and roll back at the end.', + ) + parser.add_argument( + 'commit', type=str, + help='''Target commit''' + ) + + @SubCommand.gitexec + def run(self): + target = self.args.commit + self.logger.info('Attempting fast-forward merge to %s.' % target) + self.gitcmd_run('merge', '--ff-only', target) From 6b9b77473fd8d4d0fec412c5b72e8fc21d20365d Mon Sep 17 00:00:00 2001 From: Damian Lokic Date: Mon, 27 Oct 2025 14:54:16 +0100 Subject: [PATCH 2/4] T289742: Add FF as possible zodbsync option --- perfact/zodbsync/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/perfact/zodbsync/main.py b/perfact/zodbsync/main.py index 1ca4a6f..845ccc2 100644 --- a/perfact/zodbsync/main.py +++ b/perfact/zodbsync/main.py @@ -28,6 +28,7 @@ from .commands.freeze import Freeze from .commands.layer_init import LayerInit from .commands.layer_update import LayerUpdate +from .commands.fastforward import FF class Runner(object): @@ -35,7 +36,7 @@ class Runner(object): Parses arguments to select the correct SubCommand subclass. """ commands = [Record, Playback, Watch, Pick, Upload, WithLock, Reset, Exec, - Reformat, Checkout, Freeze, LayerInit, LayerUpdate] + Reformat, Checkout, Freeze, LayerInit, LayerUpdate, FF] def __init__(self): """ From 61b2d86264d961bf9e97d983a8614f4d79bc81c0 Mon Sep 17 00:00:00 2001 From: Damian Lokic Date: Mon, 27 Oct 2025 14:54:38 +0100 Subject: [PATCH 3/4] T289742: Create test_ff to test new option --- perfact/zodbsync/tests/test_sync.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/perfact/zodbsync/tests/test_sync.py b/perfact/zodbsync/tests/test_sync.py index 7386356..a7324cc 100644 --- a/perfact/zodbsync/tests/test_sync.py +++ b/perfact/zodbsync/tests/test_sync.py @@ -715,6 +715,29 @@ def test_watch_dump_setup(self): tofind.remove(obj['path']) assert tofind == [] + def test_ff(self): + """ + Change the title on a second branch, perform a fast-forward merge to it, + and verify that the change is correctly applied. + """ + self.gitrun('checkout', '-b', 'second') + path = self.repo.path + '/__root__/index_html/__meta__' + with open(path) as f: + lines = f.readlines() + lines = [ + line if "('title', " not in line + else " ('title', 'test-ff'),\n" + for line in lines + ] + with open(path, 'w') as f: + f.writelines(lines) + self.gitrun('commit', '-a', '-m', 'Change title via ff') + + self.gitrun('checkout', 'autotest') + self.run('ff', 'second') + assert self.app.index_html.title == 'test-ff' + + def test_reset(self): """ Change the title of index_html in a second branch, reset to it and From 73fa2c4a056f5d2032969c7a7815ab19650d6056 Mon Sep 17 00:00:00 2001 From: Damian Lokic Date: Mon, 3 Nov 2025 10:02:45 +0100 Subject: [PATCH 4/4] T289742: Fix PEP8 violations --- perfact/zodbsync/commands/fastforward.py | 4 +++- perfact/zodbsync/tests/test_sync.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/perfact/zodbsync/commands/fastforward.py b/perfact/zodbsync/commands/fastforward.py index 8609f05..1e7bf5d 100644 --- a/perfact/zodbsync/commands/fastforward.py +++ b/perfact/zodbsync/commands/fastforward.py @@ -4,7 +4,9 @@ class FF(SubCommand): - '''Perform a fast-forward merge to the target commit and apply changed paths''' + ''' + Perform a fast-forward merge to the target commit and apply changed paths + ''' @staticmethod def add_args(parser): parser.add_argument( diff --git a/perfact/zodbsync/tests/test_sync.py b/perfact/zodbsync/tests/test_sync.py index a7324cc..5449907 100644 --- a/perfact/zodbsync/tests/test_sync.py +++ b/perfact/zodbsync/tests/test_sync.py @@ -717,7 +717,8 @@ def test_watch_dump_setup(self): def test_ff(self): """ - Change the title on a second branch, perform a fast-forward merge to it, + Change the title on a second branch, + perform a fast-forward merge to it, and verify that the change is correctly applied. """ self.gitrun('checkout', '-b', 'second') @@ -737,7 +738,6 @@ def test_ff(self): self.run('ff', 'second') assert self.app.index_html.title == 'test-ff' - def test_reset(self): """ Change the title of index_html in a second branch, reset to it and