Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions perfact/zodbsync/commands/fastforward.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/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)
3 changes: 2 additions & 1 deletion perfact/zodbsync/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@
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):
"""
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):
"""
Expand Down
23 changes: 23 additions & 0 deletions perfact/zodbsync/tests/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down