47
42
transport = self.get_transport()
49
44
# Create initial standalone branch
50
tree1 = self.make_branch_and_tree('standalone', 'weave')
45
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
46
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirFormat6())
47
tree1 = self.make_branch_and_tree('standalone')
48
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
51
49
self.build_tree(['standalone/a'])
53
51
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
52
out, err = self.runbzr('info standalone')
70
58
control: All-in-one format 6
98
85
# Branch standalone with push location
99
86
branch2 = branch1.bzrdir.sprout('branch').open_branch()
100
87
branch2.set_push_location(branch1.bzrdir.root_transport.base)
102
out, err = self.run_bzr('info branch')
103
self.assertEqualDiff(
104
"""Standalone tree (format: weave)
109
push branch: standalone
110
parent branch: standalone
112
self.assertEqual('', err)
114
out, err = self.run_bzr('info branch --verbose')
115
self.assertEqualDiff(
116
"""Standalone tree (format: weave)
121
push branch: standalone
122
parent branch: standalone
88
out, err = self.runbzr('info branch --verbose')
125
98
control: All-in-one format 6
158
134
# Branch and bind to standalone, needs upgrade to metadir
159
135
# (creates backup as unknown)
160
136
branch1.bzrdir.sprout('bound')
161
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
137
knit1_format = bzrlib.bzrdir.BzrDirMetaFormat1()
138
knit1_format.repository_format = repository.RepositoryFormatKnit1()
162
139
bzrlib.upgrade.upgrade('bound', knit1_format)
163
140
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
164
141
branch3.bind(branch1)
165
142
bound_tree = branch3.bzrdir.open_workingtree()
166
out, err = self.run_bzr('info -v bound')
143
out, err = self.runbzr('info bound')
167
144
self.assertEqualDiff(
168
"""Checkout (format: knit)
171
checkout of branch: standalone
147
checkout of branch: %s
173
149
Related branches:
174
parent branch: standalone
177
153
control: Meta directory format 1
155
branch: Branch format 5
182
158
In the working tree:
196
171
first revision: %s
197
172
latest revision: %s
202
""" % (bound_tree._format.get_format_description(),
203
branch3._format.get_format_description(),
177
""" % (branch3.bzrdir.root_transport.base,
178
branch1.bzrdir.root_transport.base,
179
branch1.bzrdir.root_transport.base,
180
bound_tree._format.get_format_description(),
204
181
branch3.repository._format.get_format_description(),
205
182
datestring_first, datestring_first,
206
183
# poking at _revision_store isn't all that clean, but neither is
211
188
self.assertEqual('', err)
213
190
# Checkout standalone (same as above, but does not have parent set)
214
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
191
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
192
bzrlib.bzrdir.BzrDirFormat.set_default_format(knit1_format)
193
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout')
194
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
216
195
branch4.bind(branch1)
217
196
branch4.bzrdir.open_workingtree().update()
218
out, err = self.run_bzr('info checkout --verbose')
197
out, err = self.runbzr('info checkout --verbose')
219
198
self.assertEqualDiff(
220
"""Checkout (format: knit)
222
checkout root: checkout
223
checkout of branch: standalone
201
checkout of branch: %s
226
204
control: Meta directory format 1
258
238
self.assertEqual('', err)
260
240
# Lightweight checkout (same as above, different branch and repository)
261
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
241
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
242
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
243
transport.mkdir('lightcheckout')
244
dir5 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('lightcheckout')
245
bzrlib.branch.BranchReferenceFormat().initialize(dir5, branch1)
246
dir5.create_workingtree()
247
tree5 = dir5.open_workingtree()
248
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
262
249
branch5 = tree5.branch
263
out, err = self.run_bzr('info -v lightcheckout')
250
out, err = self.runbzr('info lightcheckout')
264
251
self.assertEqualDiff(
265
"""Lightweight checkout (format: dirstate or dirstate-tags)
267
light checkout root: lightcheckout
268
checkout of branch: standalone
253
light checkout root: %s
254
checkout of branch: %s
271
257
control: Meta directory format 1
272
working tree: Working tree format 4
258
working tree: Working tree format 3
273
259
branch: Branch format 4
274
260
repository: Weave repository format 6
337
323
first revision: %s
338
324
latest revision: %s
343
""" % (datestring_first, datestring_first,
329
""" % (branch2.bzrdir.root_transport.base,
330
branch1.bzrdir.root_transport.base,
331
branch1.bzrdir.root_transport.base,
332
datestring_first, datestring_first,
345
334
self.assertEqual('', err)
347
336
# Out of date bound branch
348
out, err = self.run_bzr('info -v bound')
337
out, err = self.runbzr('info bound')
349
338
self.assertEqualDiff(
350
"""Checkout (format: knit)
353
checkout of branch: standalone
341
checkout of branch: %s
355
343
Related branches:
356
parent branch: standalone
359
347
control: Meta directory format 1
470
459
first revision: %s
471
460
latest revision: %s
476
""" % (datestring_first, datestring_last,), out)
465
""" % (tree5.bzrdir.root_transport.base,
466
branch1.bzrdir.root_transport.base,
467
datestring_first, datestring_last,
477
469
self.assertEqual('', err)
479
471
def test_info_standalone_no_tree(self):
480
472
# create standalone branch without a working tree
481
format = bzrdir.format_registry.make_bzrdir('default')
482
473
branch = self.make_branch('branch')
483
474
repo = branch.repository
484
out, err = self.run_bzr('info branch -v')
475
out, err = self.runbzr('info branch')
485
476
self.assertEqualDiff(
486
"""Standalone branch (format: dirstate or knit)
491
481
control: Meta directory format 1
482
branch: Branch format 5
502
""" % (format.get_branch_format().get_format_description(),
503
format.repository_format.get_format_description(),
491
""" % (branch.bzrdir.root_transport.base,
492
repo._format.get_format_description(),
505
494
self.assertEqual('', err)
507
496
def test_info_shared_repository(self):
508
format = bzrdir.format_registry.make_bzrdir('knit')
497
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
498
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
509
499
transport = self.get_transport()
511
501
# Create shared repository
512
repo = self.make_repository('repo', shared=True, format=format)
502
repo = self.make_repository('repo', shared=True)
513
503
repo.set_make_working_trees(False)
514
out, err = self.run_bzr('info -v repo')
504
out, err = self.runbzr('info repo')
515
505
self.assertEqualDiff(
516
"""Shared repository (format: dirstate or dirstate-tags or knit)
518
507
shared repository: %s
521
510
control: Meta directory format 1
527
""" % ('repo', format.repository_format.get_format_description(),
516
""" % (repo.bzrdir.root_transport.base,
517
repo._format.get_format_description(),
529
519
self.assertEqual('', err)
531
521
# Create branch inside shared repository
532
522
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')
523
branch1 = repo.bzrdir.create_branch_convenience('repo/branch')
524
out, err = self.runbzr('info repo/branch')
536
525
self.assertEqualDiff(
537
"""Repository branch (format: dirstate or knit)
539
shared repository: repo
540
repository branch: repo/branch
527
shared repository: %s
528
repository branch: branch
543
531
control: Meta directory format 1
532
branch: Branch format 5
554
""" % (format.get_branch_format().get_format_description(),
555
format.repository_format.get_format_description(),
541
""" % (repo.bzrdir.root_transport.base,
542
repo._format.get_format_description(),
557
544
self.assertEqual('', err)
559
546
# Create lightweight checkout
560
547
transport.mkdir('tree')
561
548
transport.mkdir('tree/lightcheckout')
562
tree2 = branch1.create_checkout('tree/lightcheckout',
549
dir2 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
550
bzrlib.branch.BranchReferenceFormat().initialize(dir2, branch1)
551
dir2.create_workingtree()
552
tree2 = dir2.open_workingtree()
564
553
branch2 = tree2.branch
565
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
566
shared_repo=repo, repo_branch=branch1, verbose=True)
554
self.assertCheckoutStatusOutput('tree/lightcheckout', tree2, shared_repo=repo)
568
556
# Create normal checkout
569
557
tree3 = branch1.create_checkout('tree/checkout')
576
564
tree2.commit('commit one')
577
565
rev = repo.get_revision(branch2.revision_history()[0])
578
566
datestring_first = format_date(rev.timestamp, rev.timezone)
579
out, err = self.run_bzr('info tree/lightcheckout --verbose')
567
out, err = self.runbzr('info tree/lightcheckout --verbose')
580
568
self.assertEqualDiff(
581
"""Lightweight checkout (format: dirstate or dirstate-tags)
583
light checkout root: tree/lightcheckout
584
checkout of branch: repo/branch
585
shared repository: repo
570
light checkout root: %s
571
shared repository: %s
572
repository branch: branch
588
575
control: Meta directory format 1
589
working tree: Working tree format 4
576
working tree: Working tree format 3
577
branch: Branch format 5
593
580
In the working tree:
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")