1457
1457
class cmd_merge(Command):
1458
"""Perform a three-way merge of trees.
1460
The SPEC parameters are working tree or revision specifiers. Working trees
1461
are specified using standard paths or urls. No component of a directory
1462
path may begin with '@'.
1464
Working tree examples: '.', '..', 'foo@', but NOT 'foo/@bar'
1466
Revisions are specified using a dirname/@revno pair, where dirname is the
1467
branch directory and revno is the revision within that branch. If no revno
1468
is specified, the latest revision is used.
1470
Revision examples: './@127', 'foo/@', '../@1'
1472
The OTHER_SPEC parameter is required. If the BASE_SPEC parameter is
1473
not supplied, the common ancestor of OTHER_SPEC the current branch is used
1458
"""Perform a three-way merge.
1460
The branch is the branch you will merge from. By default, it will merge
1461
the latest revision. If you specify a revision, that revision will be
1462
merged. If you specify two revisions, the first will be used as a BASE,
1463
and the second one as OTHER. Revision numbers are always relative to the
1468
To merge the latest revision from bzr.dev
1469
bzr merge ../bzr.dev
1471
To merge changes up to and including revision 82 from bzr.dev
1472
bzr merge -r 82 ../bzr.dev
1474
To merge the changes introduced by 82, without previous changes:
1475
bzr merge -r 81..82 ../bzr.dev
1476
1477
merge refuses to run if there are any uncommitted changes, unless
1477
1478
--force is given.
1479
takes_args = ['other_spec', 'base_spec?']
1480
takes_options = ['force', 'merge-type']
1480
takes_args = ['branch?']
1481
takes_options = ['revision', 'force', 'merge-type']
1482
def run(self, other_spec, base_spec=None, force=False, merge_type=None):
1483
def run(self, branch='.', revision=None, force=False,
1483
1485
from bzrlib.merge import merge
1484
1486
from bzrlib.merge_core import ApplyMerge3
1485
1487
if merge_type is None:
1486
1488
merge_type = ApplyMerge3
1487
merge(parse_spec(other_spec), parse_spec(base_spec),
1488
check_clean=(not force), merge_type=merge_type)
1490
if revision is None or len(revision) < 1:
1492
other = [branch, -1]
1494
if len(revision) == 1:
1495
other = [branch, revision[0]]
1498
assert len(revision) == 2
1499
if None in revision:
1500
raise BzrCommandError(
1501
"Merge doesn't permit that revision specifier.")
1502
base = (branch, revision[0])
1503
other = (branch, revision[1])
1505
merge(other, base, check_clean=(not force), merge_type=merge_type)
1491
1508
class cmd_revert(Command):