197
199
the --directory option is used to specify a different branch."""
198
200
if directory is not None:
199
201
return (None, Branch.open(directory), filename)
200
return bzrdir.BzrDir.open_containing_tree_or_branch(filename)
202
return controldir.ControlDir.open_containing_tree_or_branch(filename)
203
205
# TODO: Make sure no commands unconditionally use the working directory as a
339
341
raise errors.BzrCommandError(gettext('You must supply either'
340
342
' --revision or a revision_id'))
342
b = bzrdir.BzrDir.open_containing_tree_or_branch(directory)[1]
344
b = controldir.ControlDir.open_containing_tree_or_branch(directory)[1]
344
346
revisions = b.repository.revisions
345
347
if revisions is None:
473
475
location_list=['.']
475
477
for location in location_list:
476
d = bzrdir.BzrDir.open(location)
478
d = controldir.ControlDir.open(location)
479
481
working = d.open_workingtree()
480
482
except errors.NoWorkingTree:
556
558
_see_also = ['info']
557
559
takes_args = ['location?']
558
560
takes_options = [
559
Option('tree', help='Show revno of working tree'),
561
Option('tree', help='Show revno of working tree.'),
604
606
custom_help('directory',
605
607
help='Branch to examine, '
606
608
'rather than the one containing the working directory.'),
607
Option('tree', help='Show revno of working tree'),
609
Option('tree', help='Show revno of working tree.'),
882
884
if len(names_list) < 2:
883
885
raise errors.BzrCommandError(gettext("missing file argument"))
884
886
tree, rel_names = WorkingTree.open_containing_paths(names_list, canonicalize=False)
887
for file_name in rel_names[0:-1]:
889
raise errors.BzrCommandError(gettext("can not move root of branch"))
885
890
self.add_cleanup(tree.lock_tree_write().unlock)
886
891
self._run(tree, names_list, rel_names, after)
1185
1190
directory = '.'
1186
1191
# Get the source branch
1187
1192
(tree, br_from,
1188
_unused) = bzrdir.BzrDir.open_containing_tree_or_branch(directory)
1193
_unused) = controldir.ControlDir.open_containing_tree_or_branch(directory)
1189
1194
# Get the tip's revision_id
1190
1195
revision = _get_one_revision('push', revision)
1191
1196
if revision is not None:
1288
1293
deprecated_name=self.invoked_as,
1289
1294
recommended_name='branch',
1290
1295
deprecated_in_version='2.4')
1291
accelerator_tree, br_from = bzrdir.BzrDir.open_tree_or_branch(
1296
accelerator_tree, br_from = controldir.ControlDir.open_tree_or_branch(
1293
1298
if not (hardlink or files_from):
1294
1299
# accelerator_tree is usually slower because you have to read N
1308
1313
revision_id = br_from.last_revision()
1309
1314
if to_location is None:
1310
to_location = urlutils.derive_to_location(from_location)
1315
to_location = getattr(br_from, "name", None)
1316
if to_location is None:
1317
to_location = urlutils.derive_to_location(from_location)
1311
1318
to_transport = transport.get_transport(to_location)
1313
1320
to_transport.mkdir('.')
1314
1321
except errors.FileExists:
1315
if not use_existing_dir:
1316
raise errors.BzrCommandError(gettext('Target directory "%s" '
1317
'already exists.') % to_location)
1323
to_dir = controldir.ControlDir.open_from_transport(
1325
except errors.NotBranchError:
1326
if not use_existing_dir:
1327
raise errors.BzrCommandError(gettext('Target directory "%s" '
1328
'already exists.') % to_location)
1320
bzrdir.BzrDir.open_from_transport(to_transport)
1333
to_dir.open_branch()
1321
1334
except errors.NotBranchError:
1325
1338
except errors.NoSuchFile:
1326
1339
raise errors.BzrCommandError(gettext('Parent of "%s" does not exist.')
1329
# preserve whatever source format we have.
1330
dir = br_from.bzrdir.sprout(to_transport.base, revision_id,
1331
possible_transports=[to_transport],
1332
accelerator_tree=accelerator_tree,
1333
hardlink=hardlink, stacked=stacked,
1334
force_new_repo=standalone,
1335
create_tree_if_local=not no_tree,
1336
source_branch=br_from)
1337
branch = dir.open_branch()
1338
except errors.NoSuchRevision:
1339
to_transport.delete_tree('.')
1340
msg = gettext("The branch {0} has no revision {1}.").format(
1341
from_location, revision)
1342
raise errors.BzrCommandError(msg)
1345
# preserve whatever source format we have.
1346
to_dir = br_from.bzrdir.sprout(to_transport.base, revision_id,
1347
possible_transports=[to_transport],
1348
accelerator_tree=accelerator_tree,
1349
hardlink=hardlink, stacked=stacked,
1350
force_new_repo=standalone,
1351
create_tree_if_local=not no_tree,
1352
source_branch=br_from)
1353
branch = to_dir.open_branch()
1354
except errors.NoSuchRevision:
1355
to_transport.delete_tree('.')
1356
msg = gettext("The branch {0} has no revision {1}.").format(
1357
from_location, revision)
1358
raise errors.BzrCommandError(msg)
1360
branch = br_from.sprout(to_dir, revision_id=revision_id)
1343
1361
_merge_tags_if_possible(br_from, branch)
1344
1362
# If the source branch is stacked, the new branch may
1345
1363
# be stacked whether we asked for that explicitly or not.
1382
1400
if not t.listable():
1383
1401
raise errors.BzrCommandError(
1384
1402
"Can't scan this type of location.")
1385
for b in bzrdir.BzrDir.find_branches(t):
1403
for b in controldir.ControlDir.find_branches(t):
1386
1404
self.outf.write("%s\n" % urlutils.unescape_for_display(
1387
1405
urlutils.relative_url(t.base, b.base),
1388
1406
self.outf.encoding).rstrip("/"))
1390
dir = bzrdir.BzrDir.open_containing(location)[0]
1408
dir = controldir.ControlDir.open_containing(location)[0]
1391
1409
for branch in dir.list_branches():
1392
1410
if branch.name is None:
1393
1411
self.outf.write(gettext(" (default)\n"))
1440
1458
if branch_location is None:
1441
1459
branch_location = osutils.getcwd()
1442
1460
to_location = branch_location
1443
accelerator_tree, source = bzrdir.BzrDir.open_tree_or_branch(
1461
accelerator_tree, source = controldir.ControlDir.open_tree_or_branch(
1444
1462
branch_location)
1445
1463
if not (hardlink or files_from):
1446
1464
# accelerator_tree is usually slower because you have to read N
1655
1673
noise_level = 0
1656
1674
from bzrlib.info import show_bzrdir_info
1657
show_bzrdir_info(bzrdir.BzrDir.open_containing(location)[0],
1675
show_bzrdir_info(controldir.ControlDir.open_containing(location)[0],
1658
1676
verbose=noise_level, outfile=self.outf)
1793
1811
def run(self, branch=".", canonicalize_chks=False):
1794
1812
from bzrlib.reconcile import reconcile
1795
dir = bzrdir.BzrDir.open(branch)
1813
dir = controldir.ControlDir.open(branch)
1796
1814
reconcile(dir, canonicalize_chks=canonicalize_chks)
1807
1825
@display_command
1808
1826
def run(self, location="."):
1809
1827
branch = Branch.open_containing(location)[0]
1810
for revid in branch.revision_history():
1828
self.add_cleanup(branch.lock_read().unlock)
1829
graph = branch.repository.get_graph()
1830
history = list(graph.iter_lefthand_ancestry(branch.last_revision(),
1831
[_mod_revision.NULL_REVISION]))
1832
for revid in reversed(history):
1811
1833
self.outf.write(revid)
1812
1834
self.outf.write('\n')
1874
1896
help='Specify a format for this branch. '
1875
1897
'See "help formats".',
1876
1898
lazy_registry=('bzrlib.bzrdir', 'format_registry'),
1877
converter=lambda name: bzrdir.format_registry.make_bzrdir(name),
1899
converter=lambda name: controldir.format_registry.make_bzrdir(name),
1878
1900
value_switches=True,
1879
1901
title="Branch format",
1887
1909
def run(self, location=None, format=None, append_revisions_only=False,
1888
1910
create_prefix=False, no_tree=False):
1889
1911
if format is None:
1890
format = bzrdir.format_registry.make_bzrdir('default')
1912
format = controldir.format_registry.make_bzrdir('default')
1891
1913
if location is None:
1892
1914
location = u'.'
1910
1932
to_transport.create_prefix()
1913
a_bzrdir = bzrdir.BzrDir.open_from_transport(to_transport)
1935
a_bzrdir = controldir.ControlDir.open_from_transport(to_transport)
1914
1936
except errors.NotBranchError:
1915
1937
# really a NotBzrDir error...
1916
create_branch = bzrdir.BzrDir.create_branch_convenience
1938
create_branch = controldir.ControlDir.create_branch_convenience
1918
1940
force_new_tree = False
1992
2014
takes_options = [RegistryOption('format',
1993
2015
help='Specify a format for this repository. See'
1994
2016
' "bzr help formats" for details.',
1995
lazy_registry=('bzrlib.bzrdir', 'format_registry'),
1996
converter=lambda name: bzrdir.format_registry.make_bzrdir(name),
2017
lazy_registry=('bzrlib.controldir', 'format_registry'),
2018
converter=lambda name: controldir.format_registry.make_bzrdir(name),
1997
2019
value_switches=True, title='Repository format'),
1998
2020
Option('no-trees',
1999
2021
help='Branches in the repository will default to'
2004
2026
def run(self, location, format=None, no_trees=False):
2005
2027
if format is None:
2006
format = bzrdir.format_registry.make_bzrdir('default')
2028
format = controldir.format_registry.make_bzrdir('default')
2008
2030
if location is None:
2492
2514
help='Do not report commits with more than one parent.'),
2493
2515
Option('exclude-common-ancestry',
2494
2516
help='Display only the revisions that are not part'
2495
' of both ancestries (require -rX..Y)'
2517
' of both ancestries (require -rX..Y).'
2497
2519
Option('signatures',
2498
help='Show digital signature validity'),
2520
help='Show digital signature validity.'),
2499
2521
ListOption('match',
2500
2522
short_name='m',
2501
2523
help='Show revisions whose properties match this '
2614
2636
location = revision[0].get_branch()
2617
dir, relpath = bzrdir.BzrDir.open_containing(location)
2639
dir, relpath = controldir.ControlDir.open_containing(location)
2618
2640
b = dir.open_branch()
2619
2641
self.add_cleanup(b.lock_read().unlock)
2620
2642
rev1, rev2 = _get_revision_range(revision, b, self.name())
3603
3625
RegistryOption('format',
3604
3626
help='Upgrade to a specific format. See "bzr help'
3605
3627
' formats" for details.',
3606
lazy_registry=('bzrlib.bzrdir', 'format_registry'),
3607
converter=lambda name: bzrdir.format_registry.make_bzrdir(name),
3628
lazy_registry=('bzrlib.controldir', 'format_registry'),
3629
converter=lambda name: controldir.format_registry.make_bzrdir(name),
3608
3630
value_switches=True, title='Branch format'),
3609
3631
Option('clean',
3610
3632
help='Remove the backup.bzr directory if successful.'),
4857
4879
def run(self, branch_or_repo='.', clean_obsolete_packs=False):
4858
dir = bzrdir.BzrDir.open_containing(branch_or_repo)[0]
4880
dir = controldir.ControlDir.open_containing(branch_or_repo)[0]
4860
4882
branch = dir.open_branch()
4861
4883
repository = branch.repository
5138
5160
revision=None, force=False, local=False, keep_tags=False):
5139
5161
if location is None:
5140
5162
location = u'.'
5141
control, relpath = bzrdir.BzrDir.open_containing(location)
5163
control, relpath = controldir.ControlDir.open_containing(location)
5143
5165
tree = control.open_workingtree()
5144
5166
b = tree.branch
5248
5270
conf = _mod_config.LockableConfig(file_name=location)
5249
5271
conf.break_lock()
5251
control, relpath = bzrdir.BzrDir.open_containing(location)
5273
control, relpath = controldir.ControlDir.open_containing(location)
5253
5275
control.break_lock()
5254
5276
except NotImplementedError:
5329
5351
if protocol is None:
5330
5352
protocol = transport.transport_server_registry.get()
5331
5353
host, port = self.get_host_and_port(port)
5332
url = urlutils.local_path_to_url(directory)
5354
url = transport.location_to_url(directory)
5333
5355
if not allow_writes:
5334
5356
url = 'readonly+' + url
5335
t = transport.get_transport(url)
5357
t = transport.get_transport_from_url(url)
5337
5359
protocol(t, host, port, inet, client_timeout)
5338
5360
except TypeError, e:
5939
5961
def run(self, location=None, bind_to=None, force=False,
5940
5962
tree_type=None, repository_type=None, repository_trees=None,
5941
5963
stacked_on=None, unstacked=None):
5942
directory = bzrdir.BzrDir.open(location)
5964
directory = controldir.ControlDir.open(location)
5943
5965
if stacked_on and unstacked:
5944
5966
raise errors.BzrCommandError(gettext("Can't use both --stacked-on and --unstacked"))
5945
5967
elif stacked_on is not None:
6027
6049
from bzrlib import switch
6028
6050
tree_location = directory
6029
6051
revision = _get_one_revision('switch', revision)
6030
control_dir = bzrdir.BzrDir.open_containing(tree_location)[0]
6052
control_dir = controldir.ControlDir.open_containing(tree_location)[0]
6031
6053
if to_location is None:
6032
6054
if revision is None:
6033
6055
raise errors.BzrCommandError(gettext('You must supply either a'
6048
6070
if '/' not in to_location and '\\' not in to_location:
6049
6071
# This path is meant to be relative to the existing branch
6050
6072
this_url = self._get_branch_location(control_dir)
6051
to_location = urlutils.join(this_url, '..', to_location)
6073
# Perhaps the target control dir supports colocated branches?
6075
root = controldir.ControlDir.open(this_url,
6076
possible_transports=[control_dir.user_transport])
6077
except errors.NotBranchError:
6080
colocated = root._format.colocated_branches
6082
to_location = urlutils.join_segment_parameters(this_url,
6083
{"branch": urlutils.escape(to_location)})
6085
to_location = urlutils.join(
6086
this_url, '..', urlutils.escape(to_location))
6052
6087
to_branch = branch.bzrdir.sprout(to_location,
6053
6088
possible_transports=[branch.bzrdir.root_transport],
6054
6089
source_branch=branch).open_branch()
6091
# Perhaps it's a colocated branch?
6057
to_branch = Branch.open(to_location)
6058
except errors.NotBranchError:
6059
this_url = self._get_branch_location(control_dir)
6060
to_branch = Branch.open(
6061
urlutils.join(this_url, '..', to_location))
6093
to_branch = control_dir.open_branch(to_location)
6094
except (errors.NotBranchError, errors.NoColocatedBranchSupport):
6096
to_branch = Branch.open(to_location)
6097
except errors.NotBranchError:
6098
this_url = self._get_branch_location(control_dir)
6099
to_branch = Branch.open(
6101
this_url, '..', urlutils.escape(to_location)))
6062
6102
if revision is not None:
6063
6103
revision = revision.as_revision_id(to_branch)
6064
6104
switch.switch(control_dir, to_branch, force, revision_id=revision)