42
44
transport = self.get_transport()
44
46
# Create initial standalone branch
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)
47
tree1 = self.make_branch_and_tree('standalone', 'weave')
49
48
self.build_tree(['standalone/a'])
51
50
branch1 = tree1.branch
52
out, err = self.runbzr('info standalone')
51
out, err = self.run_bzr('info standalone -v')
53
52
self.assertEqualDiff(
53
"""Standalone tree (format: weave)
134
136
# Branch and bind to standalone, needs upgrade to metadir
135
137
# (creates backup as unknown)
136
138
branch1.bzrdir.sprout('bound')
137
knit1_format = bzrlib.bzrdir.BzrDirMetaFormat1()
138
knit1_format.repository_format = repository.RepositoryFormatKnit1()
139
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
139
140
bzrlib.upgrade.upgrade('bound', knit1_format)
140
141
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
141
142
branch3.bind(branch1)
142
143
bound_tree = branch3.bzrdir.open_workingtree()
143
out, err = self.runbzr('info bound')
144
out, err = self.run_bzr('info -v bound')
144
145
self.assertEqualDiff(
146
"""Checkout (format: knit)
146
148
checkout root: %s
147
149
checkout of branch: %s
171
174
first revision: %s
172
175
latest revision: %s
177
180
""" % (branch3.bzrdir.root_transport.base,
178
181
branch1.bzrdir.root_transport.base,
179
182
branch1.bzrdir.root_transport.base,
180
183
bound_tree._format.get_format_description(),
184
branch3._format.get_format_description(),
181
185
branch3.repository._format.get_format_description(),
182
186
datestring_first, datestring_first,
183
187
# poking at _revision_store isn't all that clean, but neither is
188
192
self.assertEqual('', err)
190
194
# Checkout standalone (same as above, but does not have parent set)
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)
195
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
195
197
branch4.bind(branch1)
196
198
branch4.bzrdir.open_workingtree().update()
197
out, err = self.runbzr('info checkout --verbose')
199
out, err = self.run_bzr('info checkout --verbose')
198
200
self.assertEqualDiff(
201
"""Checkout (format: knit)
200
203
checkout root: %s
201
204
checkout of branch: %s
238
241
self.assertEqual('', err)
240
243
# Lightweight checkout (same as above, different branch and repository)
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)
244
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
249
245
branch5 = tree5.branch
250
out, err = self.runbzr('info lightcheckout')
246
out, err = self.run_bzr('info -v lightcheckout')
251
247
self.assertEqualDiff(
253
light checkout root: %s
254
checkout of branch: %s
248
"""Lightweight checkout (format: dirstate or dirstate-tags)
250
light checkout root: %s
251
checkout of branch: %s
257
254
control: Meta directory format 1
258
working tree: Working tree format 3
255
working tree: Working tree format 4
259
256
branch: Branch format 4
260
257
repository: Weave repository format 6
471
476
def test_info_standalone_no_tree(self):
472
477
# create standalone branch without a working tree
478
format = bzrdir.format_registry.make_bzrdir('default')
473
479
branch = self.make_branch('branch')
474
480
repo = branch.repository
475
out, err = self.runbzr('info branch')
481
out, err = self.run_bzr('info branch -v')
476
482
self.assertEqualDiff(
483
"""Standalone branch (format: dirstate or knit)
481
488
control: Meta directory format 1
482
branch: Branch format 5
491
499
""" % (branch.bzrdir.root_transport.base,
492
repo._format.get_format_description(),
500
format.get_branch_format().get_format_description(),
501
format.repository_format.get_format_description(),
494
503
self.assertEqual('', err)
496
505
def test_info_shared_repository(self):
497
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
498
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
506
format = bzrdir.format_registry.make_bzrdir('knit')
499
507
transport = self.get_transport()
501
509
# Create shared repository
502
repo = self.make_repository('repo', shared=True)
510
repo = self.make_repository('repo', shared=True, format=format)
503
511
repo.set_make_working_trees(False)
504
out, err = self.runbzr('info repo')
512
out, err = self.run_bzr('info -v repo')
505
513
self.assertEqualDiff(
514
"""Shared repository (format: dirstate or dirstate-tags or knit)
507
516
shared repository: %s
510
519
control: Meta directory format 1
516
525
""" % (repo.bzrdir.root_transport.base,
517
repo._format.get_format_description(),
526
format.repository_format.get_format_description(),
519
528
self.assertEqual('', err)
521
530
# Create branch inside shared repository
522
531
repo.bzrdir.root_transport.mkdir('branch')
523
branch1 = repo.bzrdir.create_branch_convenience('repo/branch')
524
out, err = self.runbzr('info repo/branch')
532
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
534
out, err = self.run_bzr('info -v repo/branch')
525
535
self.assertEqualDiff(
536
"""Repository branch (format: dirstate or knit)
527
538
shared repository: %s
528
539
repository branch: branch
531
542
control: Meta directory format 1
532
branch: Branch format 5
541
553
""" % (repo.bzrdir.root_transport.base,
542
repo._format.get_format_description(),
554
format.get_branch_format().get_format_description(),
555
format.repository_format.get_format_description(),
544
557
self.assertEqual('', err)
546
559
# Create lightweight checkout
547
560
transport.mkdir('tree')
548
561
transport.mkdir('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()
562
tree2 = branch1.create_checkout('tree/lightcheckout',
553
564
branch2 = tree2.branch
554
self.assertCheckoutStatusOutput('tree/lightcheckout', tree2, shared_repo=repo)
565
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
566
shared_repo=repo, repo_branch=branch1, verbose=True)
556
568
# Create normal checkout
557
569
tree3 = branch1.create_checkout('tree/checkout')
564
576
tree2.commit('commit one')
565
577
rev = repo.get_revision(branch2.revision_history()[0])
566
578
datestring_first = format_date(rev.timestamp, rev.timezone)
567
out, err = self.runbzr('info tree/lightcheckout --verbose')
579
out, err = self.run_bzr('info tree/lightcheckout --verbose')
568
580
self.assertEqualDiff(
570
light checkout root: %s
571
shared repository: %s
572
repository branch: branch
581
"""Lightweight checkout (format: dirstate or dirstate-tags)
583
light checkout root: %s
584
checkout of branch: %s
585
shared repository: %s
575
588
control: Meta directory format 1
576
working tree: Working tree format 3
577
branch: Branch format 5
589
working tree: Working tree format 4
580
593
In the working tree:
594
607
first revision: %s
595
608
latest revision: %s
600
613
""" % (tree2.bzrdir.root_transport.base,
614
tree2.branch.bzrdir.root_transport.base,
601
615
repo.bzrdir.root_transport.base,
602
repo._format.get_format_description(),
616
format.get_branch_format().get_format_description(),
617
format.repository_format.get_format_description(),
603
618
datestring_first, datestring_first,
604
619
# poking at _revision_store isn't all that clean, but neither is
605
620
# having the ui test dependent on the exact overhead of a given store.
677
696
first revision: %s
678
697
latest revision: %s
683
702
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
684
repo._format.get_format_description(),
703
format.get_branch_format().get_format_description(),
704
format.repository_format.get_format_description(),
685
705
datestring_first, datestring_first,
686
706
# poking at _revision_store isn't all that clean, but neither is
687
707
# having the ui test dependent on the exact overhead of a given store.
693
713
# Out of date lightweight checkout
694
714
rev = repo.get_revision(branch1.revision_history()[-1])
695
715
datestring_last = format_date(rev.timestamp, rev.timezone)
696
out, err = self.runbzr('info tree/lightcheckout --verbose')
716
out, err = self.run_bzr('info tree/lightcheckout --verbose')
697
717
self.assertEqualDiff(
699
light checkout root: %s
700
shared repository: %s
701
repository branch: branch
718
"""Lightweight checkout (format: dirstate or dirstate-tags)
720
light checkout root: %s
721
checkout of branch: %s
722
shared repository: %s
704
725
control: Meta directory format 1
705
working tree: Working tree format 3
706
branch: Branch format 5
726
working tree: Working tree format 4
709
730
Working tree is out of date: missing 1 revision.
725
746
first revision: %s
726
747
latest revision: %s
731
752
""" % (tree2.bzrdir.root_transport.base,
753
tree2.branch.bzrdir.root_transport.base,
732
754
repo.bzrdir.root_transport.base,
733
repo._format.get_format_description(),
755
format.get_branch_format().get_format_description(),
756
format.repository_format.get_format_description(),
734
757
datestring_first, datestring_last,
735
758
# poking at _revision_store isn't all that clean, but neither is
736
759
# having the ui test dependent on the exact overhead of a given store.
770
795
self.assertEqual('', err)
772
797
# Show info about repository with revisions
773
out, err = self.runbzr('info repo')
798
out, err = self.run_bzr('info -v repo')
774
799
self.assertEqualDiff(
800
"""Shared repository (format: dirstate or dirstate-tags or knit)
776
802
shared repository: %s
779
805
control: Meta directory format 1
785
811
""" % (repo.bzrdir.root_transport.base,
786
repo._format.get_format_description(),
812
format.repository_format.get_format_description(),
787
813
# poking at _revision_store isn't all that clean, but neither is
788
814
# having the ui test dependent on the exact overhead of a given store.
789
815
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
791
817
self.assertEqual('', err)
793
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
795
819
def test_info_shared_repository_with_trees(self):
796
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
797
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
820
format = bzrdir.format_registry.make_bzrdir('knit')
798
821
transport = self.get_transport()
800
823
# Create shared repository with working trees
801
repo = self.make_repository('repo', shared=True)
824
repo = self.make_repository('repo', shared=True, format=format)
802
825
repo.set_make_working_trees(True)
803
out, err = self.runbzr('info repo')
826
out, err = self.run_bzr('info -v repo')
804
827
self.assertEqualDiff(
828
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
806
830
shared repository: %s
812
836
Create working tree for new branches inside the repository.
817
841
""" % (repo.bzrdir.root_transport.base,
818
repo._format.get_format_description(),
842
format.repository_format.get_format_description(),
820
844
self.assertEqual('', err)
822
846
# Create two branches
823
847
repo.bzrdir.root_transport.mkdir('branch1')
824
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1')
848
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
825
850
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
827
852
# Empty first branch
828
out, err = self.runbzr('info repo/branch1 --verbose')
853
out, err = self.run_bzr('info repo/branch1 --verbose')
829
854
self.assertEqualDiff(
831
shared repository: %s
832
repository checkout: branch1
855
"""Repository tree (format: knit)
857
shared repository: %s
858
repository branch: branch1
835
861
control: Meta directory format 1
836
862
working tree: Working tree format 3
837
branch: Branch format 5
840
866
In the working tree:
866
893
tree1.commit('commit one')
867
894
rev = repo.get_revision(branch1.revision_history()[0])
868
895
datestring_first = format_date(rev.timestamp, rev.timezone)
869
out, err = self.runbzr('info repo/branch1')
896
out, err = self.run_bzr('info -v repo/branch1')
870
897
self.assertEqualDiff(
872
shared repository: %s
873
repository checkout: branch1
898
"""Repository tree (format: knit)
900
shared repository: %s
901
repository branch: branch1
876
904
control: Meta directory format 1
877
905
working tree: Working tree format 3
878
branch: Branch format 5
881
909
In the working tree:
942
973
""" % (repo.bzrdir.root_transport.base,
943
974
branch1.bzrdir.root_transport.base,
944
repo._format.get_format_description(),
975
format.get_branch_format().get_format_description(),
976
format.repository_format.get_format_description(),
945
977
# poking at _revision_store isn't all that clean, but neither is
946
978
# having the ui test dependent on the exact overhead of a given store.
947
979
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
982
1016
first revision: %s
983
1017
latest revision: %s
988
1022
""" % (repo.bzrdir.root_transport.base,
989
1023
branch1.bzrdir.root_transport.base,
990
repo._format.get_format_description(),
1024
format.get_branch_format().get_format_description(),
1025
format.repository_format.get_format_description(),
991
1026
datestring_first, datestring_first,
992
1027
# poking at _revision_store isn't all that clean, but neither is
993
1028
# having the ui test dependent on the exact overhead of a given store.
1008
1044
Create working tree for new branches inside the repository.
1013
1049
""" % (repo.bzrdir.root_transport.base,
1014
repo._format.get_format_description(),
1050
format.repository_format.get_format_description(),
1015
1051
# poking at _revision_store isn't all that clean, but neither is
1016
1052
# having the ui test dependent on the exact overhead of a given store.
1017
1053
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1020
1056
self.assertEqual('', err)
1022
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1024
1058
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())
1059
format = bzrdir.format_registry.make_bzrdir('knit')
1027
1060
transport = self.get_transport()
1029
1062
# Create shared repository with working trees
1030
repo = self.make_repository('repo', shared=True)
1063
repo = self.make_repository('repo', shared=True, format=format)
1031
1064
repo.set_make_working_trees(True)
1032
out, err = self.runbzr('info repo')
1065
out, err = self.run_bzr('info -v repo')
1033
1066
self.assertEqualDiff(
1067
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1035
1069
shared repository: %s
1077
1112
Branch history:
1083
1119
""" % (repo.bzrdir.root_transport.base,
1084
repo._format.get_format_description(),
1120
format.get_branch_format().get_format_description(),
1121
format.repository_format.get_format_description(),
1086
1123
self.assertEqual('', err)
1088
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1090
1125
def assertCheckoutStatusOutput(self,
1091
1126
command_string, lco_tree, shared_repo=None,
1092
1127
repo_branch=None,
1093
1128
tree_locked=False,
1094
1129
branch_locked=False, repo_locked=False,
1096
light_checkout=True):
1097
"""Check the output of info in a light checkout tree.
1131
light_checkout=True,
1132
checkout_root=None):
1133
"""Check the output of info in a checkout.
1099
1135
This is not quite a mirror of the info code: rather than using the
1100
1136
tree being examined to predict output, it uses a bunch of flags which
1113
1149
:param repo_locked: If true, expect the repository to be locked.
1114
1150
:param verbose: If true, expect verbose output
1116
out, err = self.runbzr('info %s' % command_string)
1152
if tree_locked and sys.platform == 'win32':
1153
# We expect this to fail because of locking errors. (A write-locked
1154
# file cannot be read-locked in the same process).
1155
# This should be removed when the locking errors are fixed.
1156
args = command_string.split(' ')
1157
self.run_bzr_error([], 'info', *args)
1159
out, err = self.run_bzr('info %s' % command_string)
1161
(True, True): 'Lightweight checkout',
1162
(True, False): 'Repository checkout',
1163
(False, True): 'Lightweight checkout',
1164
(False, False): 'Checkout',
1165
}[(shared_repo is not None, light_checkout)]
1166
format = {True: 'dirstate or dirstate-tags',
1167
False: 'dirstate'}[light_checkout]
1117
1168
if repo_locked or branch_locked or tree_locked:
1118
1169
def locked_message(a_bool):
1131
1182
locked_message(repo_locked)))
1133
1184
expected_lock_output = ''
1134
1187
if light_checkout:
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)
1188
tree_data = (" light checkout root: %s\n" %
1189
lco_tree.bzrdir.root_transport.base)
1191
if lco_tree.branch.get_bound_location() is not None:
1192
tree_data += ("%s checkout root: %s\n" % (extra_space,
1193
lco_tree.branch.bzrdir.root_transport.base))
1140
1194
if shared_repo is not None:
1141
1195
branch_data = (
1142
" shared repository: %s\n"
1143
" repository branch: branch\n" %
1144
shared_repo.bzrdir.root_transport.base)
1196
" checkout of branch: %s\n"
1197
" shared repository: %s\n" %
1198
(repo_branch.bzrdir.root_transport.base,
1199
shared_repo.bzrdir.root_transport.base))
1145
1200
elif repo_branch is not None:
1146
1201
branch_data = (
1147
" checkout of branch: %s\n" %
1148
repo_branch.bzrdir.root_transport.base)
1202
"%s checkout of branch: %s\n" %
1204
repo_branch.bzrdir.root_transport.base))
1150
branch_data = (" checkout of branch: %s\n" %
1206
branch_data = (" checkout of branch: %s\n" %
1151
1207
lco_tree.branch.bzrdir.root_transport.base)
1219
self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
1278
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1279
repo_branch=repo_branch,
1280
verbose=True, light_checkout=True)
1221
1282
lco_tree.branch.repository.lock_write()
1223
self.assertCheckoutStatusOutput('tree/lightcheckout',
1284
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1285
lco_tree, repo_branch=repo_branch,
1286
repo_locked=True, verbose=True, light_checkout=True)
1227
1288
lco_tree.branch.repository.unlock()
1229
1290
lco_tree.branch.lock_write()
1231
self.assertCheckoutStatusOutput('tree/lightcheckout',
1292
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1233
1294
branch_locked=True,
1296
repo_branch=repo_branch,
1236
1299
lco_tree.branch.unlock()
1238
1301
lco_tree.lock_write()
1240
self.assertCheckoutStatusOutput('tree/lightcheckout',
1303
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1304
lco_tree, repo_branch=repo_branch,
1242
1305
tree_locked=True,
1243
1306
branch_locked=True,
1246
1310
lco_tree.unlock()
1248
1312
lco_tree.lock_write()
1249
1313
lco_tree.branch.repository.unlock()
1251
self.assertCheckoutStatusOutput('tree/lightcheckout',
1315
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1316
lco_tree, repo_branch=repo_branch,
1253
1317
tree_locked=True,
1256
1321
lco_tree.branch.repository.lock_write()
1257
1322
lco_tree.unlock()
1282
1349
lco_tree.branch.lock_write()
1283
1350
lco_tree.branch.repository.unlock()
1285
self.assertCheckoutStatusOutput('tree/lightcheckout',
1352
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1353
lco_tree, repo_branch=repo_branch,
1289
1357
lco_tree.branch.repository.lock_write()
1290
1358
lco_tree.branch.unlock()
1360
if sys.platform == 'win32':
1361
self.knownFailure('Win32 cannot run "bzr info"'
1362
' when the tree is locked.')
1292
1364
def test_info_locking_oslocks(self):
1293
1365
if sys.platform == "win32":
1294
1366
raise TestSkipped("don't use oslocks on win32 in unix manner")