125
def get_merge_type(typestring):
126
"""Attempt to find the merge class/factory associated with a string."""
127
from merge import merge_types
129
return merge_types[typestring][0]
131
templ = '%s%%7s: %%s' % (' '*12)
132
lines = [templ % (f[0], f[1][1]) for f in merge_types.iteritems()]
133
type_list = '\n'.join(lines)
134
msg = "No known merge type %s. Supported types are:\n%s" %\
135
(typestring, type_list)
136
raise BzrCommandError(msg)
126
140
def _get_cmd_dict(plugins_override=True):
1404
1418
--force is given.
1406
1420
takes_args = ['other_spec', 'base_spec?']
1407
takes_options = ['force']
1421
takes_options = ['force', 'merge-type']
1409
def run(self, other_spec, base_spec=None, force=False):
1423
def run(self, other_spec, base_spec=None, force=False, merge_type=None):
1410
1424
from bzrlib.merge import merge
1425
from bzrlib.merge_core import ApplyMerge3
1426
if merge_type is None:
1427
merge_type = ApplyMerge3
1411
1428
merge(parse_spec(other_spec), parse_spec(base_spec),
1412
check_clean=(not force))
1429
check_clean=(not force), merge_type=merge_type)
1416
1432
class cmd_revert(Command):
1417
"""Restore selected files from a previous revision.
1419
takes_args = ['file+']
1420
def run(self, file_list):
1421
from bzrlib.branch import find_branch
1426
b = find_branch(file_list[0])
1428
b.revert([b.relpath(f) for f in file_list])
1431
class cmd_merge_revert(Command):
1432
1433
"""Reverse all changes since the last commit.
1434
Only versioned files are affected.
1436
TODO: Store backups of any files that will be reverted, so
1437
that the revert can be undone.
1435
Only versioned files are affected. Specify filenames to revert only
1436
those files. By default, any files that are changed will be backed up
1437
first. Backup files have a '~' appended to their name.
1439
takes_options = ['revision']
1439
takes_options = ['revision', 'no-backup']
1440
takes_args = ['file*']
1441
aliases = ['merge-revert']
1441
def run(self, revision=None):
1443
def run(self, revision=None, no_backup=False, file_list=None):
1442
1444
from bzrlib.merge import merge
1445
if file_list is not None:
1446
if len(file_list) == 0:
1447
raise BzrCommandError("No files specified")
1443
1448
if revision is None:
1444
1449
revision = [-1]
1445
1450
elif len(revision) != 1:
1446
raise BzrCommandError('bzr merge-revert --revision takes exactly 1 argument')
1451
raise BzrCommandError('bzr revert --revision takes exactly 1 argument')
1447
1452
merge(('.', revision[0]), parse_spec('.'),
1448
1453
check_clean=False,
1455
backup_files=not no_backup,
1456
file_list=file_list)
1452
1459
class cmd_assert_fail(Command):