112
""" % (branch2.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
113
branch1.bzrdir.root_transport.base,
114
datestring_first, datestring_first), out)
122
""" % (branch2.bzrdir.root_transport.base,
123
branch1.bzrdir.root_transport.base,
124
branch1.bzrdir.root_transport.base,
125
datestring_first, datestring_first,
126
# poking at _revision_store isn't all that clean, but neither is
127
# having the ui test dependent on the exact overhead of a given store.
128
branch2.repository._revision_store.total_size(
129
branch2.repository.get_transaction())[1] / 1024,
115
131
self.assertEqual('', err)
117
133
# Branch and bind to standalone, needs upgrade to metadir
118
134
# (creates backup as unknown)
119
# XXX: I can't get this to work through API
120
self.runbzr('branch standalone bound')
121
#branch3 = branch1.bzrdir.sprout('bound').open_branch()
122
self.runbzr('upgrade --format=metadir bound')
123
#bzrlib.upgrade.upgrade('bound', 'metadir')
135
branch1.bzrdir.sprout('bound')
136
bzrlib.upgrade.upgrade('bound', bzrlib.bzrdir.BzrDirMetaFormat1())
124
137
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
125
138
branch3.bind(branch1)
139
bound_tree = branch3.bzrdir.open_workingtree()
126
140
out, err = self.runbzr('info bound')
127
141
self.assertEqualDiff(
144
checkout of branch: %s
134
150
control: Meta directory format 1
135
working tree: Working tree format 3
136
152
branch: Branch format 5
492
548
dir2.create_workingtree()
493
549
tree2 = dir2.open_workingtree()
494
550
branch2 = tree2.branch
495
out, err = self.runbzr('info tree/lightcheckout')
496
self.assertEqualDiff(
499
checkout of branch: %s
500
shared repository: %s
503
control: Meta directory format 1
504
working tree: Working tree format 3
505
branch: Branch format 5
516
0 versioned subdirectories
524
""" % (tree2.bzrdir.root_transport.base,
525
branch1.bzrdir.root_transport.base,
526
repo.bzrdir.root_transport.base,
527
repo._format.get_format_description(),
529
self.assertEqual('', err)
551
self.assertCheckoutStatusOutput('tree/lightcheckout', tree2, shared_repo=repo)
531
553
# Create normal checkout
532
554
branch3 = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout')
533
555
branch3.bind(branch1)
534
556
tree3 = branch3.bzrdir.open_workingtree()
536
out, err = self.runbzr('info tree/checkout --verbose')
537
self.assertEqualDiff(
543
control: Meta directory format 1
544
working tree: Working tree format 3
545
branch: Branch format 5
556
0 versioned subdirectories
565
""" % (branch3.bzrdir.root_transport.base,
566
branch1.bzrdir.root_transport.base,
567
repo._format.get_format_description(),
569
self.assertEqual('', err)
558
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
560
light_checkout=False, repo_branch=branch1)
571
561
# Update lightweight checkout
572
562
self.build_tree(['tree/lightcheckout/a'])
1032
1020
self.assertEqual('', err)
1034
1022
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1024
def test_info_shared_repository_with_tree_in_root(self):
1025
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
1026
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
1027
transport = self.get_transport()
1029
# Create shared repository with working trees
1030
repo = self.make_repository('repo', shared=True)
1031
repo.set_make_working_trees(True)
1032
out, err = self.runbzr('info repo')
1033
self.assertEqualDiff(
1035
shared repository: %s
1038
control: Meta directory format 1
1041
Create working tree for new branches inside the repository.
1046
""" % (repo.bzrdir.root_transport.base,
1047
repo._format.get_format_description(),
1049
self.assertEqual('', err)
1051
# Create branch in root of repository
1052
control = repo.bzrdir
1053
branch = control.create_branch()
1054
control.create_workingtree()
1055
out, err = self.runbzr('info repo')
1056
self.assertEqualDiff(
1058
shared repository: %s
1059
repository checkout: .
1062
control: Meta directory format 1
1063
working tree: Working tree format 3
1064
branch: Branch format 5
1067
In the working tree:
1075
0 versioned subdirectories
1083
""" % (repo.bzrdir.root_transport.base,
1084
repo._format.get_format_description(),
1086
self.assertEqual('', err)
1088
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1090
def assertCheckoutStatusOutput(self,
1091
command_string, lco_tree, shared_repo=None,
1094
branch_locked=False, repo_locked=False,
1096
light_checkout=True):
1097
"""Check the output of info in a light checkout tree.
1099
This is not quite a mirror of the info code: rather than using the
1100
tree being examined to predict output, it uses a bunch of flags which
1101
allow us, the test writers, to document what *should* be present in
1102
the output. Removing this separation would remove the value of the
1105
:param path: the path to the light checkout.
1106
:param lco_tree: the tree object for the light checkout.
1107
:param shared_repo: A shared repository is in use, expect that in
1109
:param repo_branch: A branch in a shared repository for non light
1111
:param tree_locked: If true, expect the tree to be locked.
1112
:param branch_locked: If true, expect the branch to be locked.
1113
:param repo_locked: If true, expect the repository to be locked.
1114
:param verbose: If true, expect verbose output
1116
out, err = self.runbzr('info %s' % command_string)
1117
if repo_locked or branch_locked or tree_locked:
1118
def locked_message(a_bool):
1123
expected_lock_output = (
1126
" working tree: %s\n"
1128
" repository: %s\n" % (
1129
locked_message(tree_locked),
1130
locked_message(branch_locked),
1131
locked_message(repo_locked)))
1133
expected_lock_output = ''
1135
tree_data = (" light checkout root: %s" %
1136
lco_tree.bzrdir.root_transport.base)
1138
tree_data = (" checkout root: %s" %
1139
lco_tree.bzrdir.root_transport.base)
1140
if shared_repo is not None:
1142
" shared repository: %s\n"
1143
" repository branch: branch\n" %
1144
shared_repo.bzrdir.root_transport.base)
1145
elif repo_branch is not None:
1147
" checkout of branch: %s\n" %
1148
repo_branch.bzrdir.root_transport.base)
1150
branch_data = (" checkout of branch: %s\n" %
1151
lco_tree.branch.bzrdir.root_transport.base)
1154
verbose_info = ' 0 committers\n'
1158
self.assertEqualDiff(
1163
control: Meta directory format 1
1165
branch: Branch format 5
1168
In the working tree:
1176
0 versioned subdirectories
1186
lco_tree._format.get_format_description(),
1187
lco_tree.branch.repository._format.get_format_description(),
1188
expected_lock_output,
1191
self.assertEqual('', err)
1193
def test_info_locking(self):
1194
transport = self.get_transport()
1195
# Create shared repository with a branch
1196
repo = self.make_repository('repo', shared=True,
1197
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1198
repo.set_make_working_trees(False)
1199
repo.bzrdir.root_transport.mkdir('branch')
1200
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1201
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1202
# Do a heavy checkout
1203
transport.mkdir('tree')
1204
transport.mkdir('tree/checkout')
1205
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1206
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1207
co_branch.bind(repo_branch)
1208
# Do a light checkout of the heavy one
1209
transport.mkdir('tree/lightcheckout')
1210
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1211
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1212
lco_dir.create_workingtree()
1213
lco_tree = lco_dir.open_workingtree()
1215
# Test all permutations of locking the working tree, branch and repository
1219
self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
1221
lco_tree.branch.repository.lock_write()
1223
self.assertCheckoutStatusOutput('tree/lightcheckout',
1227
lco_tree.branch.repository.unlock()
1229
lco_tree.branch.lock_write()
1231
self.assertCheckoutStatusOutput('tree/lightcheckout',
1236
lco_tree.branch.unlock()
1238
lco_tree.lock_write()
1240
self.assertCheckoutStatusOutput('tree/lightcheckout',
1248
lco_tree.lock_write()
1249
lco_tree.branch.repository.unlock()
1251
self.assertCheckoutStatusOutput('tree/lightcheckout',
1256
lco_tree.branch.repository.lock_write()
1259
lco_tree.lock_write()
1260
lco_tree.branch.unlock()
1262
self.assertCheckoutStatusOutput('tree/lightcheckout',
1266
lco_tree.branch.lock_write()
1269
lco_tree.lock_write()
1270
lco_tree.branch.unlock()
1271
lco_tree.branch.repository.lock_write()
1273
self.assertCheckoutStatusOutput('tree/lightcheckout',
1278
lco_tree.branch.repository.unlock()
1279
lco_tree.branch.lock_write()
1282
lco_tree.branch.lock_write()
1283
lco_tree.branch.repository.unlock()
1285
self.assertCheckoutStatusOutput('tree/lightcheckout',
1289
lco_tree.branch.repository.lock_write()
1290
lco_tree.branch.unlock()
1292
def test_info_locking_oslocks(self):
1293
if sys.platform == "win32":
1294
raise TestSkipped("don't use oslocks on win32 in unix manner")
1296
tree = self.make_branch_and_tree('branch',
1297
format=bzrlib.bzrdir.BzrDirFormat6())
1299
# Test all permutations of locking the working tree, branch and repository
1300
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1301
# implemented by raising NotImplementedError and get_physical_lock_status()
1302
# always returns false. This makes bzr info hide the lock status. (Olaf)
1306
out, err = self.runbzr('info branch')
1307
self.assertEqualDiff(
1312
control: All-in-one format 6
1313
working tree: Working tree format 2
1314
branch: Branch format 4
1317
In the working tree:
1325
0 versioned subdirectories
1333
""" % (tree.bzrdir.root_transport.base,
1334
tree.branch.repository._format.get_format_description(),
1336
self.assertEqual('', err)
1339
out, err = self.runbzr('info branch')
1340
self.assertEqualDiff(
1345
control: All-in-one format 6
1346
working tree: Working tree format 2
1347
branch: Branch format 4
1350
In the working tree:
1358
0 versioned subdirectories
1366
""" % (tree.bzrdir.root_transport.base,
1367
tree.branch.repository._format.get_format_description(),
1369
self.assertEqual('', err)