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):
1457
1469
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
1470
"""Perform a three-way merge.
1472
The branch is the branch you will merge from. By default, it will merge
1473
the latest revision. If you specify a revision, that revision will be
1474
merged. If you specify two revisions, the first will be used as a BASE,
1475
and the second one as OTHER. Revision numbers are always relative to the
1480
To merge the latest revision from bzr.dev
1481
bzr merge ../bzr.dev
1483
To merge changes up to and including revision 82 from bzr.dev
1484
bzr merge -r 82 ../bzr.dev
1486
To merge the changes introduced by 82, without previous changes:
1487
bzr merge -r 81..82 ../bzr.dev
1476
1489
merge refuses to run if there are any uncommitted changes, unless
1477
1490
--force is given.
1479
takes_args = ['other_spec', 'base_spec?']
1480
takes_options = ['force', 'merge-type']
1492
takes_args = ['branch?']
1493
takes_options = ['revision', 'force', 'merge-type']
1482
def run(self, other_spec, base_spec=None, force=False, merge_type=None):
1495
def run(self, branch='.', revision=None, force=False,
1483
1497
from bzrlib.merge import merge
1484
1498
from bzrlib.merge_core import ApplyMerge3
1485
1499
if merge_type is None:
1486
1500
merge_type = ApplyMerge3
1487
merge(parse_spec(other_spec), parse_spec(base_spec),
1488
check_clean=(not force), merge_type=merge_type)
1502
if revision is None or len(revision) < 1:
1504
other = (branch, -1)
1506
if len(revision) == 1:
1507
other = (branch, revision[0])
1510
assert len(revision) == 2
1511
if None in revision:
1512
raise BzrCommandError(
1513
"Merge doesn't permit that revision specifier.")
1514
base = (branch, revision[0])
1515
other = (branch, revision[1])
1517
merge(other, base, check_clean=(not force), merge_type=merge_type)
1491
1520
class cmd_revert(Command):
1534
1563
help.help(topic)
1566
class cmd_shell_complete(Command):
1567
"""Show appropriate completions for context.
1569
For a list of all available commands, say 'bzr shell-complete'."""
1570
takes_args = ['context?']
1574
def run(self, context=None):
1575
import shellcomplete
1576
shellcomplete.shellcomplete(context)
1539
1579
class cmd_missing(Command):
1901
1938
def main(argv):
1903
1939
bzrlib.trace.open_tracefile(argv)
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()
1943
return run_bzr(argv[1:])
1945
# do this here inside the exception wrappers to catch EPIPE
1947
except BzrCommandError, e:
1948
# command line syntax error, etc
1952
bzrlib.trace.log_exception()
1954
except AssertionError, e:
1955
bzrlib.trace.log_exception('assertion failed: ' + str(e))
1957
except KeyboardInterrupt, e:
1958
bzrlib.trace.note('interrupted')
1960
except Exception, e:
1962
if (isinstance(e, IOError)
1963
and hasattr(e, 'errno')
1964
and e.errno == errno.EPIPE):
1965
bzrlib.trace.note('broken pipe')
1968
bzrlib.trace.log_exception('terminated by exception')
1945
1972
if __name__ == '__main__':