710
717
msg = "The branch %s has no revision %d." % (from_location,
712
719
raise BzrCommandError(msg)
714
721
merge((to_location, -1), (to_location, 0), this_dir=to_location,
715
722
check_clean=False, ignore_zero=True)
716
723
from_location = pull_loc(br_from)
1381
1388
takes_options = ['email']
1383
1390
def run(self, email=False):
1392
b = bzrlib.branch.find_branch('.')
1385
print bzrlib.osutils.user_email()
1397
print bzrlib.osutils.user_email(b)
1387
print bzrlib.osutils.username()
1399
print bzrlib.osutils.username(b)
1390
1402
class cmd_selftest(Command):
1393
1405
takes_options = ['verbose']
1394
1406
def run(self, verbose=False):
1395
1408
from bzrlib.selftest import selftest
1396
return int(not selftest(verbose=verbose))
1410
# we don't want progress meters from the tests to go to the
1413
save_ui = bzrlib.ui.ui_factory
1415
bzrlib.ui.ui_factory = bzrlib.ui.SilentUIFactory()
1416
return int(not selftest(verbose=verbose))
1418
bzrlib.ui.ui_factory = save_ui
1399
1421
class cmd_version(Command):
1457
1479
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
1480
"""Perform a three-way merge.
1482
The branch is the branch you will merge from. By default, it will merge
1483
the latest revision. If you specify a revision, that revision will be
1484
merged. If you specify two revisions, the first will be used as a BASE,
1485
and the second one as OTHER. Revision numbers are always relative to the
1490
To merge the latest revision from bzr.dev
1491
bzr merge ../bzr.dev
1493
To merge changes up to and including revision 82 from bzr.dev
1494
bzr merge -r 82 ../bzr.dev
1496
To merge the changes introduced by 82, without previous changes:
1497
bzr merge -r 81..82 ../bzr.dev
1476
1499
merge refuses to run if there are any uncommitted changes, unless
1477
1500
--force is given.
1479
takes_args = ['other_spec', 'base_spec?']
1480
takes_options = ['force', 'merge-type']
1502
takes_args = ['branch?']
1503
takes_options = ['revision', 'force', 'merge-type']
1482
def run(self, other_spec, base_spec=None, force=False, merge_type=None):
1505
def run(self, branch='.', revision=None, force=False,
1483
1507
from bzrlib.merge import merge
1484
1508
from bzrlib.merge_core import ApplyMerge3
1485
1509
if merge_type is None:
1486
1510
merge_type = ApplyMerge3
1487
merge(parse_spec(other_spec), parse_spec(base_spec),
1488
check_clean=(not force), merge_type=merge_type)
1512
if revision is None or len(revision) < 1:
1514
other = (branch, -1)
1516
if len(revision) == 1:
1517
other = (branch, revision[0])
1520
assert len(revision) == 2
1521
if None in revision:
1522
raise BzrCommandError(
1523
"Merge doesn't permit that revision specifier.")
1524
base = (branch, revision[0])
1525
other = (branch, revision[1])
1527
merge(other, base, check_clean=(not force), merge_type=merge_type)
1491
1530
class cmd_revert(Command):
1534
1573
help.help(topic)
1576
class cmd_shell_complete(Command):
1577
"""Show appropriate completions for context.
1579
For a list of all available commands, say 'bzr shell-complete'."""
1580
takes_args = ['context?']
1584
def run(self, context=None):
1585
import shellcomplete
1586
shellcomplete.shellcomplete(context)
1539
1589
class cmd_missing(Command):
1901
1949
def main(argv):
1903
1952
bzrlib.trace.open_tracefile(argv)
1954
bzrlib.ui.ui_factory = bzrlib.ui.TextUIFactory()
1908
return run_bzr(argv[1:])
1910
# do this here inside the exception wrappers to catch EPIPE
1913
quiet = isinstance(e, (BzrCommandError))
1914
_report_exception('error: ' + str(e), quiet=quiet)
1917
# some explanation or hints
1920
except AssertionError, e:
1921
msg = 'assertion failed'
1923
msg += ': ' + str(e)
1924
_report_exception(msg)
1926
except KeyboardInterrupt, e:
1927
_report_exception('interrupted', quiet=True)
1929
except Exception, e:
1932
if (isinstance(e, IOError)
1933
and hasattr(e, 'errno')
1934
and e.errno == errno.EPIPE):
1938
msg = str(e).rstrip('\n')
1939
_report_exception(msg, quiet)
1942
bzrlib.trace.close_trace()
1958
return run_bzr(argv[1:])
1960
# do this here inside the exception wrappers to catch EPIPE
1962
except BzrCommandError, e:
1963
# command line syntax error, etc
1967
bzrlib.trace.log_exception()
1969
except AssertionError, e:
1970
bzrlib.trace.log_exception('assertion failed: ' + str(e))
1972
except KeyboardInterrupt, e:
1973
bzrlib.trace.note('interrupted')
1975
except Exception, e:
1977
if (isinstance(e, IOError)
1978
and hasattr(e, 'errno')
1979
and e.errno == errno.EPIPE):
1980
bzrlib.trace.note('broken pipe')
1983
bzrlib.trace.log_exception('terminated by exception')
1945
1987
if __name__ == '__main__':