47
41
transport = self.get_transport()
49
43
# Create initial standalone branch
50
tree1 = self.make_branch_and_tree('standalone', 'weave')
44
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
45
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirFormat6())
46
tree1 = self.make_branch_and_tree('standalone')
47
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
51
48
self.build_tree(['standalone/a'])
53
50
branch1 = tree1.branch
55
out, err = self.run_bzr('info standalone')
57
"""Standalone tree (format: weave)
59
branch root: standalone
61
self.assertEqual('', err)
63
out, err = self.run_bzr('info standalone -v')
65
"""Standalone tree (format: weave)
67
branch root: standalone
51
out, err = self.runbzr('info standalone')
70
57
control: All-in-one format 6
158
133
# Branch and bind to standalone, needs upgrade to metadir
159
134
# (creates backup as unknown)
160
135
branch1.bzrdir.sprout('bound')
161
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
162
bzrlib.upgrade.upgrade('bound', knit1_format)
136
bzrlib.upgrade.upgrade('bound', bzrlib.bzrdir.BzrDirMetaFormat1())
163
137
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
164
138
branch3.bind(branch1)
165
139
bound_tree = branch3.bzrdir.open_workingtree()
166
out, err = self.run_bzr('info -v bound')
140
out, err = self.runbzr('info bound')
167
141
self.assertEqualDiff(
168
"""Checkout (format: knit)
171
checkout of branch: standalone
144
checkout of branch: %s
173
146
Related branches:
174
parent branch: standalone
177
150
control: Meta directory format 1
152
branch: Branch format 5
182
155
In the working tree:
211
185
self.assertEqual('', err)
213
187
# Checkout standalone (same as above, but does not have parent set)
214
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
188
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
189
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
190
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout')
191
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
216
192
branch4.bind(branch1)
217
193
branch4.bzrdir.open_workingtree().update()
218
out, err = self.run_bzr('info checkout --verbose')
194
out, err = self.runbzr('info checkout --verbose')
219
195
self.assertEqualDiff(
220
"""Checkout (format: knit)
222
checkout root: checkout
223
checkout of branch: standalone
198
checkout of branch: %s
226
201
control: Meta directory format 1
258
235
self.assertEqual('', err)
260
237
# Lightweight checkout (same as above, different branch and repository)
261
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
238
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
239
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
240
transport.mkdir('lightcheckout')
241
dir5 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('lightcheckout')
242
bzrlib.branch.BranchReferenceFormat().initialize(dir5, branch1)
243
dir5.create_workingtree()
244
tree5 = dir5.open_workingtree()
245
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
262
246
branch5 = tree5.branch
263
out, err = self.run_bzr('info -v lightcheckout')
247
out, err = self.runbzr('info lightcheckout')
264
248
self.assertEqualDiff(
265
"""Lightweight checkout (format: dirstate or dirstate-tags)
267
light checkout root: lightcheckout
268
checkout of branch: standalone
250
light checkout root: %s
251
checkout of branch: %s
271
254
control: Meta directory format 1
272
working tree: Working tree format 4
255
working tree: Working tree format 3
273
256
branch: Branch format 4
274
257
repository: Weave repository format 6
337
320
first revision: %s
338
321
latest revision: %s
343
""" % (datestring_first, datestring_first,
326
""" % (branch2.bzrdir.root_transport.base,
327
branch1.bzrdir.root_transport.base,
328
branch1.bzrdir.root_transport.base,
329
datestring_first, datestring_first,
345
331
self.assertEqual('', err)
347
333
# Out of date bound branch
348
out, err = self.run_bzr('info -v bound')
334
out, err = self.runbzr('info bound')
349
335
self.assertEqualDiff(
350
"""Checkout (format: knit)
353
checkout of branch: standalone
338
checkout of branch: %s
355
340
Related branches:
356
parent branch: standalone
359
344
control: Meta directory format 1
470
456
first revision: %s
471
457
latest revision: %s
476
""" % (datestring_first, datestring_last,), out)
462
""" % (tree5.bzrdir.root_transport.base,
463
branch1.bzrdir.root_transport.base,
464
datestring_first, datestring_last,
477
466
self.assertEqual('', err)
479
468
def test_info_standalone_no_tree(self):
480
469
# create standalone branch without a working tree
481
format = bzrdir.format_registry.make_bzrdir('default')
482
470
branch = self.make_branch('branch')
483
471
repo = branch.repository
484
out, err = self.run_bzr('info branch -v')
472
out, err = self.runbzr('info branch')
485
473
self.assertEqualDiff(
486
"""Standalone branch (format: dirstate or knit)
491
478
control: Meta directory format 1
479
branch: Branch format 5
502
""" % (format.get_branch_format().get_format_description(),
503
format.repository_format.get_format_description(),
488
""" % (branch.bzrdir.root_transport.base,
489
repo._format.get_format_description(),
505
491
self.assertEqual('', err)
507
493
def test_info_shared_repository(self):
508
format = bzrdir.format_registry.make_bzrdir('knit')
494
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
495
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
509
496
transport = self.get_transport()
511
498
# Create shared repository
512
repo = self.make_repository('repo', shared=True, format=format)
499
repo = self.make_repository('repo', shared=True)
513
500
repo.set_make_working_trees(False)
514
out, err = self.run_bzr('info -v repo')
501
out, err = self.runbzr('info repo')
515
502
self.assertEqualDiff(
516
"""Shared repository (format: dirstate or dirstate-tags or knit)
518
504
shared repository: %s
521
507
control: Meta directory format 1
527
""" % ('repo', format.repository_format.get_format_description(),
513
""" % (repo.bzrdir.root_transport.base,
514
repo._format.get_format_description(),
529
516
self.assertEqual('', err)
531
518
# Create branch inside shared repository
532
519
repo.bzrdir.root_transport.mkdir('branch')
533
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
535
out, err = self.run_bzr('info -v repo/branch')
520
branch1 = repo.bzrdir.create_branch_convenience('repo/branch')
521
out, err = self.runbzr('info repo/branch')
536
522
self.assertEqualDiff(
537
"""Repository branch (format: dirstate or knit)
539
shared repository: repo
540
repository branch: repo/branch
524
shared repository: %s
525
repository branch: branch
543
528
control: Meta directory format 1
529
branch: Branch format 5
554
""" % (format.get_branch_format().get_format_description(),
555
format.repository_format.get_format_description(),
538
""" % (repo.bzrdir.root_transport.base,
539
repo._format.get_format_description(),
557
541
self.assertEqual('', err)
559
543
# Create lightweight checkout
560
544
transport.mkdir('tree')
561
545
transport.mkdir('tree/lightcheckout')
562
tree2 = branch1.create_checkout('tree/lightcheckout',
546
dir2 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
547
bzrlib.branch.BranchReferenceFormat().initialize(dir2, branch1)
548
dir2.create_workingtree()
549
tree2 = dir2.open_workingtree()
564
550
branch2 = tree2.branch
565
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
566
shared_repo=repo, repo_branch=branch1, verbose=True)
551
self.assertCheckoutStatusOutput('tree/lightcheckout', tree2, shared_repo=repo)
568
553
# Create normal checkout
569
tree3 = branch1.create_checkout('tree/checkout')
554
branch3 = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout')
555
branch3.bind(branch1)
556
tree3 = branch3.bzrdir.open_workingtree()
570
558
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
572
560
light_checkout=False, repo_branch=branch1)
707
693
# Out of date lightweight checkout
708
694
rev = repo.get_revision(branch1.revision_history()[-1])
709
695
datestring_last = format_date(rev.timestamp, rev.timezone)
710
out, err = self.run_bzr('info tree/lightcheckout --verbose')
696
out, err = self.runbzr('info tree/lightcheckout --verbose')
711
697
self.assertEqualDiff(
712
"""Lightweight checkout (format: dirstate or dirstate-tags)
714
light checkout root: tree/lightcheckout
715
checkout of branch: repo/branch
716
shared repository: repo
699
light checkout root: %s
700
shared repository: %s
701
repository branch: branch
719
704
control: Meta directory format 1
720
working tree: Working tree format 4
705
working tree: Working tree format 3
706
branch: Branch format 5
724
709
Working tree is out of date: missing 1 revision.
785
770
self.assertEqual('', err)
787
772
# Show info about repository with revisions
788
out, err = self.run_bzr('info -v repo')
773
out, err = self.runbzr('info repo')
789
774
self.assertEqualDiff(
790
"""Shared repository (format: dirstate or dirstate-tags or knit)
792
shared repository: repo
776
shared repository: %s
795
779
control: Meta directory format 1
801
""" % (format.repository_format.get_format_description(),
785
""" % (repo.bzrdir.root_transport.base,
786
repo._format.get_format_description(),
802
787
# poking at _revision_store isn't all that clean, but neither is
803
788
# having the ui test dependent on the exact overhead of a given store.
804
789
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
806
791
self.assertEqual('', err)
793
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
808
795
def test_info_shared_repository_with_trees(self):
809
format = bzrdir.format_registry.make_bzrdir('knit')
796
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
797
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
810
798
transport = self.get_transport()
812
800
# Create shared repository with working trees
813
repo = self.make_repository('repo', shared=True, format=format)
801
repo = self.make_repository('repo', shared=True)
814
802
repo.set_make_working_trees(True)
815
out, err = self.run_bzr('info -v repo')
803
out, err = self.runbzr('info repo')
816
804
self.assertEqualDiff(
817
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
819
shared repository: repo
806
shared repository: %s
822
809
control: Meta directory format 1
825
812
Create working tree for new branches inside the repository.
830
""" % (format.repository_format.get_format_description(),
817
""" % (repo.bzrdir.root_transport.base,
818
repo._format.get_format_description(),
832
820
self.assertEqual('', err)
834
822
# Create two branches
835
823
repo.bzrdir.root_transport.mkdir('branch1')
836
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
824
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1')
838
825
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
840
827
# Empty first branch
841
out, err = self.run_bzr('info repo/branch1 --verbose')
828
out, err = self.runbzr('info repo/branch1 --verbose')
842
829
self.assertEqualDiff(
843
"""Repository tree (format: knit)
845
shared repository: repo
846
repository branch: repo/branch1
831
shared repository: %s
832
repository checkout: branch1
849
835
control: Meta directory format 1
850
836
working tree: Working tree format 3
837
branch: Branch format 5
854
840
In the working tree:
1026
1008
Create working tree for new branches inside the repository.
1031
""" % (format.repository_format.get_format_description(),
1013
""" % (repo.bzrdir.root_transport.base,
1014
repo._format.get_format_description(),
1032
1015
# poking at _revision_store isn't all that clean, but neither is
1033
1016
# having the ui test dependent on the exact overhead of a given store.
1034
1017
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1037
1020
self.assertEqual('', err)
1022
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1039
1024
def test_info_shared_repository_with_tree_in_root(self):
1040
format = bzrdir.format_registry.make_bzrdir('knit')
1025
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
1026
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
1041
1027
transport = self.get_transport()
1043
1029
# Create shared repository with working trees
1044
repo = self.make_repository('repo', shared=True, format=format)
1030
repo = self.make_repository('repo', shared=True)
1045
1031
repo.set_make_working_trees(True)
1046
out, err = self.run_bzr('info -v repo')
1032
out, err = self.runbzr('info repo')
1047
1033
self.assertEqualDiff(
1048
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1050
shared repository: repo
1035
shared repository: %s
1053
1038
control: Meta directory format 1
1092
1077
Branch history:
1099
""" % (format.get_branch_format().get_format_description(),
1100
format.repository_format.get_format_description(),
1083
""" % (repo.bzrdir.root_transport.base,
1084
repo._format.get_format_description(),
1102
1086
self.assertEqual('', err)
1088
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1104
1090
def assertCheckoutStatusOutput(self,
1105
1091
command_string, lco_tree, shared_repo=None,
1106
1092
repo_branch=None,
1107
1093
tree_locked=False,
1108
1094
branch_locked=False, repo_locked=False,
1110
light_checkout=True,
1111
checkout_root=None):
1112
"""Check the output of info in a checkout.
1096
light_checkout=True):
1097
"""Check the output of info in a light checkout tree.
1114
1099
This is not quite a mirror of the info code: rather than using the
1115
1100
tree being examined to predict output, it uses a bunch of flags which
1128
1113
:param repo_locked: If true, expect the repository to be locked.
1129
1114
:param verbose: If true, expect verbose output
1131
def friendly_location(url):
1132
path = urlutils.unescape_for_display(url, 'ascii')
1134
return osutils.relpath(os.getcwd(), path)
1135
except errors.PathNotChild:
1138
if tree_locked and sys.platform == 'win32':
1139
# We expect this to fail because of locking errors. (A write-locked
1140
# file cannot be read-locked in the same process).
1141
# This should be removed when the locking errors are fixed.
1142
args = command_string.split(' ')
1143
self.run_bzr_error([], 'info', *args)
1145
out, err = self.run_bzr('info %s' % command_string)
1147
(True, True): 'Lightweight checkout',
1148
(True, False): 'Repository checkout',
1149
(False, True): 'Lightweight checkout',
1150
(False, False): 'Checkout',
1151
}[(shared_repo is not None, light_checkout)]
1152
format = {True: 'dirstate or dirstate-tags',
1153
False: 'dirstate'}[light_checkout]
1116
out, err = self.runbzr('info %s' % command_string)
1154
1117
if repo_locked or branch_locked or tree_locked:
1155
1118
def locked_message(a_bool):
1168
1131
locked_message(repo_locked)))
1170
1133
expected_lock_output = ''
1173
1134
if light_checkout:
1174
tree_data = (" light checkout root: %s\n" %
1175
friendly_location(lco_tree.bzrdir.root_transport.base))
1177
if lco_tree.branch.get_bound_location() is not None:
1178
tree_data += ("%s checkout root: %s\n" % (extra_space,
1179
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
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)
1180
1140
if shared_repo is not None:
1181
1141
branch_data = (
1182
" checkout of branch: %s\n"
1183
" shared repository: %s\n" %
1184
(friendly_location(repo_branch.bzrdir.root_transport.base),
1185
friendly_location(shared_repo.bzrdir.root_transport.base)))
1142
" shared repository: %s\n"
1143
" repository branch: branch\n" %
1144
shared_repo.bzrdir.root_transport.base)
1186
1145
elif repo_branch is not None:
1187
1146
branch_data = (
1188
"%s checkout of branch: %s\n" %
1190
friendly_location(repo_branch.bzrdir.root_transport.base)))
1147
" checkout of branch: %s\n" %
1148
repo_branch.bzrdir.root_transport.base)
1192
branch_data = (" checkout of branch: %s\n" %
1150
branch_data = (" checkout of branch: %s\n" %
1193
1151
lco_tree.branch.bzrdir.root_transport.base)
1264
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1265
repo_branch=repo_branch,
1266
verbose=True, light_checkout=True)
1219
self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
1268
1221
lco_tree.branch.repository.lock_write()
1270
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1271
lco_tree, repo_branch=repo_branch,
1272
repo_locked=True, verbose=True, light_checkout=True)
1223
self.assertCheckoutStatusOutput('tree/lightcheckout',
1274
1227
lco_tree.branch.repository.unlock()
1276
1229
lco_tree.branch.lock_write()
1278
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1231
self.assertCheckoutStatusOutput('tree/lightcheckout',
1280
1233
branch_locked=True,
1282
repo_branch=repo_branch,
1285
1236
lco_tree.branch.unlock()
1287
1238
lco_tree.lock_write()
1289
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1290
lco_tree, repo_branch=repo_branch,
1240
self.assertCheckoutStatusOutput('tree/lightcheckout',
1291
1242
tree_locked=True,
1292
1243
branch_locked=True,
1296
1246
lco_tree.unlock()
1298
1248
lco_tree.lock_write()
1299
1249
lco_tree.branch.repository.unlock()
1301
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1302
lco_tree, repo_branch=repo_branch,
1251
self.assertCheckoutStatusOutput('tree/lightcheckout',
1303
1253
tree_locked=True,
1307
1256
lco_tree.branch.repository.lock_write()
1308
1257
lco_tree.unlock()
1335
1282
lco_tree.branch.lock_write()
1336
1283
lco_tree.branch.repository.unlock()
1338
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1339
lco_tree, repo_branch=repo_branch,
1285
self.assertCheckoutStatusOutput('tree/lightcheckout',
1343
1289
lco_tree.branch.repository.lock_write()
1344
1290
lco_tree.branch.unlock()
1346
if sys.platform == 'win32':
1347
self.knownFailure('Win32 cannot run "bzr info"'
1348
' when the tree is locked.')
1350
1292
def test_info_locking_oslocks(self):
1351
1293
if sys.platform == "win32":
1352
1294
raise TestSkipped("don't use oslocks on win32 in unix manner")