141
141
raise BzrCommandError(msg)
144
def get_merge_type(typestring):
145
"""Attempt to find the merge class/factory associated with a string."""
146
from merge import merge_types
148
return merge_types[typestring][0]
150
templ = '%s%%7s: %%s' % (' '*12)
151
lines = [templ % (f[0], f[1][1]) for f in merge_types.iteritems()]
152
type_list = '\n'.join(lines)
153
msg = "No known merge type %s. Supported types are:\n%s" %\
154
(typestring, type_list)
155
raise BzrCommandError(msg)
145
159
def _get_cmd_dict(plugins_override=True):
872
889
b = find_branch('.')
874
# TODO: Make show_diff support taking 2 arguments
876
891
if revision is not None:
877
if len(revision) != 1:
878
raise BzrCommandError('bzr diff --revision takes exactly one revision identifier')
879
base_rev = revision[0]
881
show_diff(b, base_rev, specific_files=file_list,
882
external_diff_options=diff_options)
892
if len(revision) == 1:
893
show_diff(b, revision[0], specific_files=file_list,
894
external_diff_options=diff_options)
895
elif len(revision) == 2:
896
show_diff(b, revision[0], specific_files=file_list,
897
external_diff_options=diff_options,
898
revision2=revision[1])
900
raise BzrCommandError('bzr diff --revision takes exactly one or two revision identifiers')
902
show_diff(b, None, specific_files=file_list,
903
external_diff_options=diff_options)
969
989
takes_args = ['filename?']
970
takes_options = ['forward', 'timezone', 'verbose', 'show-ids', 'revision','long', 'message']
990
takes_options = ['forward', 'timezone', 'verbose', 'show-ids', 'revision',
991
'long', 'message', 'short',]
972
993
def run(self, filename=None, timezone='original',
1359
1381
takes_options = ['email']
1361
1383
def run(self, email=False):
1385
b = bzrlib.branch.find_branch('.')
1363
print bzrlib.osutils.user_email()
1390
print bzrlib.osutils.user_email(b)
1365
print bzrlib.osutils.username()
1392
print bzrlib.osutils.username(b)
1368
1395
class cmd_selftest(Command):
1435
1462
class cmd_merge(Command):
1436
"""Perform a three-way merge of trees.
1438
The SPEC parameters are working tree or revision specifiers. Working trees
1439
are specified using standard paths or urls. No component of a directory
1440
path may begin with '@'.
1442
Working tree examples: '.', '..', 'foo@', but NOT 'foo/@bar'
1444
Revisions are specified using a dirname/@revno pair, where dirname is the
1445
branch directory and revno is the revision within that branch. If no revno
1446
is specified, the latest revision is used.
1448
Revision examples: './@127', 'foo/@', '../@1'
1450
The OTHER_SPEC parameter is required. If the BASE_SPEC parameter is
1451
not supplied, the common ancestor of OTHER_SPEC the current branch is used
1463
"""Perform a three-way merge.
1465
The branch is the branch you will merge from. By default, it will merge
1466
the latest revision. If you specify a revision, that revision will be
1467
merged. If you specify two revisions, the first will be used as a BASE,
1468
and the second one as OTHER. Revision numbers are always relative to the
1473
To merge the latest revision from bzr.dev
1474
bzr merge ../bzr.dev
1476
To merge changes up to and including revision 82 from bzr.dev
1477
bzr merge -r 82 ../bzr.dev
1479
To merge the changes introduced by 82, without previous changes:
1480
bzr merge -r 81..82 ../bzr.dev
1454
1482
merge refuses to run if there are any uncommitted changes, unless
1455
1483
--force is given.
1457
takes_args = ['other_spec', 'base_spec?']
1458
takes_options = ['force', 'merge-type']
1485
takes_args = ['branch?']
1486
takes_options = ['revision', 'force', 'merge-type']
1460
def run(self, other_spec, base_spec=None, force=False, merge_type=None):
1488
def run(self, branch='.', revision=None, force=False,
1461
1490
from bzrlib.merge import merge
1462
1491
from bzrlib.merge_core import ApplyMerge3
1463
1492
if merge_type is None:
1464
1493
merge_type = ApplyMerge3
1465
merge(parse_spec(other_spec), parse_spec(base_spec),
1466
check_clean=(not force), merge_type=merge_type)
1495
if revision is None or len(revision) < 1:
1497
other = (branch, -1)
1499
if len(revision) == 1:
1500
other = (branch, revision[0])
1503
assert len(revision) == 2
1504
if None in revision:
1505
raise BzrCommandError(
1506
"Merge doesn't permit that revision specifier.")
1507
base = (branch, revision[0])
1508
other = (branch, revision[1])
1510
merge(other, base, check_clean=(not force), merge_type=merge_type)
1469
1513
class cmd_revert(Command):
1561
class cmd_missing(Command):
1562
"""What is missing in this branch relative to other branch.
1564
takes_args = ['remote?']
1565
aliases = ['mis', 'miss']
1566
# We don't have to add quiet to the list, because
1567
# unknown options are parsed as booleans
1568
takes_options = ['verbose', 'quiet']
1570
def run(self, remote=None, verbose=False, quiet=False):
1571
from bzrlib.branch import find_branch, DivergedBranches
1572
from bzrlib.errors import BzrCommandError
1573
from bzrlib.missing import get_parent, show_missing
1575
if verbose and quiet:
1576
raise BzrCommandError('Cannot pass both quiet and verbose')
1578
b = find_branch('.')
1579
parent = get_parent(b)
1582
raise BzrCommandError("No missing location known or specified.")
1585
print "Using last location: %s" % parent
1587
elif parent is None:
1588
# We only update x-pull if it did not exist, missing should not change the parent
1589
b.controlfile('x-pull', 'wb').write(remote + '\n')
1590
br_remote = find_branch(remote)
1592
return show_missing(b, br_remote, verbose=verbose, quiet=quiet)
1517
1595
class cmd_plugins(Command):
1518
1596
"""List plugins"""