1387
1387
class cmd_merge(Command):
1388
"""Perform a three-way merge of trees.
1390
The SPEC parameters are working tree or revision specifiers. Working trees
1391
are specified using standard paths or urls. No component of a directory
1392
path may begin with '@'.
1394
Working tree examples: '.', '..', 'foo@', but NOT 'foo/@bar'
1396
Revisions are specified using a dirname/@revno pair, where dirname is the
1397
branch directory and revno is the revision within that branch. If no revno
1398
is specified, the latest revision is used.
1400
Revision examples: './@127', 'foo/@', '../@1'
1402
The OTHER_SPEC parameter is required. If the BASE_SPEC parameter is
1403
not supplied, the common ancestor of OTHER_SPEC the current branch is used
1388
"""Perform a three-way merge.
1390
The branch is the branch you will merge from. By default, it will merge
1391
the latest revision. If you specify a revision, that revision will be
1392
merged. If you specify two revisions, the first will be used as a BASE,
1393
and the second one as OTHER. Revision numbers are always relative to the
1398
To merge the latest revision from bzr.dev
1399
bzr merge ../bzr.dev
1401
To merge changes up to and including revision 82 from bzr.dev
1402
bzr merge -r 82 ../bzr.dev
1404
To merge the changes introduced by 82, without previous changes:
1405
bzr merge -r 81..82 ../bzr.dev
1406
1407
merge refuses to run if there are any uncommitted changes, unless
1407
1408
--force is given.
1409
takes_args = ['other_spec', 'base_spec?']
1410
takes_options = ['force', 'merge-type']
1410
takes_args = ['branch?']
1411
takes_options = ['revision', 'force', 'merge-type']
1412
def run(self, other_spec, base_spec=None, force=False, merge_type=None):
1413
def run(self, branch='.', revision=None, force=False,
1413
1415
from bzrlib.merge import merge
1414
1416
from bzrlib.merge_core import ApplyMerge3
1415
1417
if merge_type is None:
1416
1418
merge_type = ApplyMerge3
1417
merge(parse_spec(other_spec), parse_spec(base_spec),
1418
check_clean=(not force), merge_type=merge_type)
1420
if revision is None or len(revision) < 1:
1422
other = (branch, -1)
1424
if len(revision) == 1:
1425
other = (branch, revision[0])
1428
assert len(revision) == 2
1429
if None in revision:
1430
raise BzrCommandError(
1431
"Merge doesn't permit that revision specifier.")
1432
base = (branch, revision[0])
1433
other = (branch, revision[1])
1435
merge(other, base, check_clean=(not force), merge_type=merge_type)
1421
1438
class cmd_revert(Command):