1
# Copyright (C) 2006, 2007 Canonical Ltd
1
# Copyright (C) 2006 by Canonical Ltd
2
# -*- coding: utf-8 -*-
3
4
# This program is free software; you can redistribute it and/or modify
4
5
# it under the terms of the GNU General Public License as published by
44
41
transport = self.get_transport()
46
43
# Create initial standalone branch
47
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)
48
48
self.build_tree(['standalone/a'])
50
50
branch1 = tree1.branch
133
133
# Branch and bind to standalone, needs upgrade to metadir
134
134
# (creates backup as unknown)
135
135
branch1.bzrdir.sprout('bound')
136
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
137
bzrlib.upgrade.upgrade('bound', knit1_format)
136
bzrlib.upgrade.upgrade('bound', bzrlib.bzrdir.BzrDirMetaFormat1())
138
137
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
139
138
branch3.bind(branch1)
140
139
bound_tree = branch3.bzrdir.open_workingtree()
169
168
first revision: %s
170
169
latest revision: %s
175
174
""" % (branch3.bzrdir.root_transport.base,
176
175
branch1.bzrdir.root_transport.base,
177
176
branch1.bzrdir.root_transport.base,
178
177
bound_tree._format.get_format_description(),
179
branch3._format.get_format_description(),
180
178
branch3.repository._format.get_format_description(),
181
179
datestring_first, datestring_first,
182
180
# poking at _revision_store isn't all that clean, but neither is
187
185
self.assertEqual('', err)
189
187
# Checkout standalone (same as above, but does not have parent set)
190
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)
192
192
branch4.bind(branch1)
193
193
branch4.bzrdir.open_workingtree().update()
194
194
out, err = self.runbzr('info checkout --verbose')
235
235
self.assertEqual('', err)
237
237
# Lightweight checkout (same as above, different branch and repository)
238
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)
239
246
branch5 = tree5.branch
240
247
out, err = self.runbzr('info lightcheckout')
241
248
self.assertEqualDiff(
461
468
def test_info_standalone_no_tree(self):
462
469
# create standalone branch without a working tree
463
format = bzrdir.format_registry.make_bzrdir('default')
464
470
branch = self.make_branch('branch')
465
471
repo = branch.repository
466
472
out, err = self.runbzr('info branch')
472
478
control: Meta directory format 1
479
branch: Branch format 5
482
488
""" % (branch.bzrdir.root_transport.base,
483
format.get_branch_format().get_format_description(),
484
format.repository_format.get_format_description(),
489
repo._format.get_format_description(),
486
491
self.assertEqual('', err)
488
493
def test_info_shared_repository(self):
489
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())
490
496
transport = self.get_transport()
492
498
# Create shared repository
493
repo = self.make_repository('repo', shared=True, format=format)
499
repo = self.make_repository('repo', shared=True)
494
500
repo.set_make_working_trees(False)
495
501
out, err = self.runbzr('info repo')
496
502
self.assertEqualDiff(
501
507
control: Meta directory format 1
507
513
""" % (repo.bzrdir.root_transport.base,
508
format.repository_format.get_format_description(),
514
repo._format.get_format_description(),
510
516
self.assertEqual('', err)
512
518
# Create branch inside shared repository
513
519
repo.bzrdir.root_transport.mkdir('branch')
514
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
520
branch1 = repo.bzrdir.create_branch_convenience('repo/branch')
516
521
out, err = self.runbzr('info repo/branch')
517
522
self.assertEqualDiff(
523
528
control: Meta directory format 1
529
branch: Branch format 5
533
538
""" % (repo.bzrdir.root_transport.base,
534
format.get_branch_format().get_format_description(),
535
format.repository_format.get_format_description(),
539
repo._format.get_format_description(),
537
541
self.assertEqual('', err)
539
543
# Create lightweight checkout
540
544
transport.mkdir('tree')
541
545
transport.mkdir('tree/lightcheckout')
542
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()
544
550
branch2 = tree2.branch
545
self.assertCheckoutStatusOutput('tree/lightcheckout', tree2,
551
self.assertCheckoutStatusOutput('tree/lightcheckout', tree2, shared_repo=repo)
548
553
# Create normal checkout
549
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()
550
558
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
552
560
light_checkout=False, repo_branch=branch1)
586
594
first revision: %s
587
595
latest revision: %s
592
600
""" % (tree2.bzrdir.root_transport.base,
593
601
repo.bzrdir.root_transport.base,
594
format.get_branch_format().get_format_description(),
595
format.repository_format.get_format_description(),
602
repo._format.get_format_description(),
596
603
datestring_first, datestring_first,
597
604
# poking at _revision_store isn't all that clean, but neither is
598
605
# having the ui test dependent on the exact overhead of a given store.
634
641
""" % (tree3.bzrdir.root_transport.base,
635
642
branch1.bzrdir.root_transport.base,
636
format.get_branch_format().get_format_description(),
637
format.repository_format.get_format_description(),
643
repo._format.get_format_description(),
639
645
self.assertEqual('', err)
671
677
first revision: %s
672
678
latest revision: %s
677
683
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
678
format.get_branch_format().get_format_description(),
679
format.repository_format.get_format_description(),
684
repo._format.get_format_description(),
680
685
datestring_first, datestring_first,
681
686
# poking at _revision_store isn't all that clean, but neither is
682
687
# having the ui test dependent on the exact overhead of a given store.
720
725
first revision: %s
721
726
latest revision: %s
726
731
""" % (tree2.bzrdir.root_transport.base,
727
732
repo.bzrdir.root_transport.base,
728
format.get_branch_format().get_format_description(),
729
format.repository_format.get_format_description(),
733
repo._format.get_format_description(),
730
734
datestring_first, datestring_last,
731
735
# poking at _revision_store isn't all that clean, but neither is
732
736
# having the ui test dependent on the exact overhead of a given store.
753
757
first revision: %s
754
758
latest revision: %s
759
763
""" % (repo.bzrdir.root_transport.base,
760
format.get_branch_format().get_format_description(),
761
format.repository_format.get_format_description(),
764
repo._format.get_format_description(),
762
765
datestring_first, datestring_last,
763
766
# poking at _revision_store isn't all that clean, but neither is
764
767
# having the ui test dependent on the exact overhead of a given store.
776
779
control: Meta directory format 1
782
785
""" % (repo.bzrdir.root_transport.base,
783
format.repository_format.get_format_description(),
786
repo._format.get_format_description(),
784
787
# poking at _revision_store isn't all that clean, but neither is
785
788
# having the ui test dependent on the exact overhead of a given store.
786
789
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
788
791
self.assertEqual('', err)
793
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
790
795
def test_info_shared_repository_with_trees(self):
791
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())
792
798
transport = self.get_transport()
794
800
# Create shared repository with working trees
795
repo = self.make_repository('repo', shared=True, format=format)
801
repo = self.make_repository('repo', shared=True)
796
802
repo.set_make_working_trees(True)
797
803
out, err = self.runbzr('info repo')
798
804
self.assertEqualDiff(
806
812
Create working tree for new branches inside the repository.
811
817
""" % (repo.bzrdir.root_transport.base,
812
format.repository_format.get_format_description(),
818
repo._format.get_format_description(),
814
820
self.assertEqual('', err)
816
822
# Create two branches
817
823
repo.bzrdir.root_transport.mkdir('branch1')
818
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
824
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1')
820
825
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
822
827
# Empty first branch
852
857
""" % (repo.bzrdir.root_transport.base,
853
format.get_branch_format().get_format_description(),
854
format.repository_format.get_format_description(),
858
repo._format.get_format_description(),
856
860
self.assertEqual('', err)
890
894
first revision: %s
891
895
latest revision: %s
896
900
""" % (repo.bzrdir.root_transport.base,
897
format.get_branch_format().get_format_description(),
898
format.repository_format.get_format_description(),
901
repo._format.get_format_description(),
899
902
datestring_first, datestring_first,
900
903
# poking at _revision_store isn't all that clean, but neither is
901
904
# having the ui test dependent on the exact overhead of a given store.
939
942
""" % (repo.bzrdir.root_transport.base,
940
943
branch1.bzrdir.root_transport.base,
941
format.get_branch_format().get_format_description(),
942
format.repository_format.get_format_description(),
944
repo._format.get_format_description(),
943
945
# poking at _revision_store isn't all that clean, but neither is
944
946
# having the ui test dependent on the exact overhead of a given store.
945
947
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
980
982
first revision: %s
981
983
latest revision: %s
986
988
""" % (repo.bzrdir.root_transport.base,
987
989
branch1.bzrdir.root_transport.base,
988
format.get_branch_format().get_format_description(),
989
format.repository_format.get_format_description(),
990
repo._format.get_format_description(),
990
991
datestring_first, datestring_first,
991
992
# poking at _revision_store isn't all that clean, but neither is
992
993
# having the ui test dependent on the exact overhead of a given store.
1007
1008
Create working tree for new branches inside the repository.
1012
1013
""" % (repo.bzrdir.root_transport.base,
1013
format.repository_format.get_format_description(),
1014
repo._format.get_format_description(),
1014
1015
# poking at _revision_store isn't all that clean, but neither is
1015
1016
# having the ui test dependent on the exact overhead of a given store.
1016
1017
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1019
1020
self.assertEqual('', err)
1022
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1021
1024
def test_info_shared_repository_with_tree_in_root(self):
1022
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())
1023
1027
transport = self.get_transport()
1025
1029
# Create shared repository with working trees
1026
repo = self.make_repository('repo', shared=True, format=format)
1030
repo = self.make_repository('repo', shared=True)
1027
1031
repo.set_make_working_trees(True)
1028
1032
out, err = self.runbzr('info repo')
1029
1033
self.assertEqualDiff(
1037
1041
Create working tree for new branches inside the repository.
1042
1046
""" % (repo.bzrdir.root_transport.base,
1043
format.repository_format.get_format_description(),
1047
repo._format.get_format_description(),
1045
1049
self.assertEqual('', err)
1073
1077
Branch history:
1079
1083
""" % (repo.bzrdir.root_transport.base,
1080
format.get_branch_format().get_format_description(),
1081
format.repository_format.get_format_description(),
1084
repo._format.get_format_description(),
1083
1086
self.assertEqual('', err)
1088
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1085
1090
def assertCheckoutStatusOutput(self,
1086
1091
command_string, lco_tree, shared_repo=None,
1087
1092
repo_branch=None,
1108
1113
:param repo_locked: If true, expect the repository to be locked.
1109
1114
:param verbose: If true, expect verbose output
1111
if tree_locked and sys.platform == 'win32':
1112
# We expect this to fail because of locking errors. (A write-locked
1113
# file cannot be read-locked in the same process).
1114
# This should be removed when the locking errors are fixed.
1115
args = command_string.split(' ')
1116
self.run_bzr_error([], 'info', *args)
1118
1116
out, err = self.runbzr('info %s' % command_string)
1119
1117
if repo_locked or branch_locked or tree_locked:
1120
1118
def locked_message(a_bool):
1180
1178
Branch history:
1186
1184
""" % (tree_data,
1188
1186
lco_tree._format.get_format_description(),
1189
lco_tree.branch._format.get_format_description(),
1190
1187
lco_tree.branch.repository._format.get_format_description(),
1191
1188
expected_lock_output,
1206
1203
transport.mkdir('tree')
1207
1204
transport.mkdir('tree/checkout')
1208
1205
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1209
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1206
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1210
1207
co_branch.bind(repo_branch)
1211
1208
# Do a light checkout of the heavy one
1212
1209
transport.mkdir('tree/lightcheckout')
1292
1289
lco_tree.branch.repository.lock_write()
1293
1290
lco_tree.branch.unlock()
1295
if sys.platform == 'win32':
1296
self.knownFailure('Win32 cannot run "bzr info"'
1297
' when the tree is locked.')
1299
1292
def test_info_locking_oslocks(self):
1300
1293
if sys.platform == "win32":
1301
1294
raise TestSkipped("don't use oslocks on win32 in unix manner")