40
33
location = "C:/i/do/not/exist/"
42
35
location = "/i/do/not/exist/"
43
out, err = self.run_bzr('info '+location, retcode=3)
36
out, err = self.runbzr('info '+location, retcode=3)
44
37
self.assertEqual(out, '')
45
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
38
self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
47
40
def test_info_standalone(self):
48
41
transport = self.get_transport()
50
43
# Create initial standalone branch
51
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)
52
48
self.build_tree(['standalone/a'])
54
50
branch1 = tree1.branch
56
out, err = self.run_bzr('info standalone')
58
"""Standalone tree (format: weave)
60
branch root: standalone
62
self.assertEqual('', err)
64
out, err = self.run_bzr('info standalone -v')
66
"""Standalone tree (format: weave)
68
branch root: standalone
51
out, err = self.runbzr('info standalone')
71
57
control: All-in-one format 6
99
84
# Branch standalone with push location
100
85
branch2 = branch1.bzrdir.sprout('branch').open_branch()
101
86
branch2.set_push_location(branch1.bzrdir.root_transport.base)
103
out, err = self.run_bzr('info branch')
104
self.assertEqualDiff(
105
"""Standalone tree (format: weave)
110
push branch: standalone
111
parent branch: standalone
113
self.assertEqual('', err)
115
out, err = self.run_bzr('info branch --verbose')
116
self.assertEqualDiff(
117
"""Standalone tree (format: weave)
122
push branch: standalone
123
parent branch: standalone
87
out, err = self.runbzr('info branch --verbose')
126
97
control: All-in-one format 6
159
133
# Branch and bind to standalone, needs upgrade to metadir
160
134
# (creates backup as unknown)
161
135
branch1.bzrdir.sprout('bound')
162
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
163
bzrlib.upgrade.upgrade('bound', knit1_format)
136
bzrlib.upgrade.upgrade('bound', bzrlib.bzrdir.BzrDirMetaFormat1())
164
137
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
165
138
branch3.bind(branch1)
166
139
bound_tree = branch3.bzrdir.open_workingtree()
167
out, err = self.run_bzr('info -v bound')
140
out, err = self.runbzr('info bound')
168
141
self.assertEqualDiff(
169
"""Checkout (format: knit)
172
checkout of branch: standalone
144
checkout of branch: %s
174
146
Related branches:
175
parent branch: standalone
178
150
control: Meta directory format 1
152
branch: Branch format 5
183
155
In the working tree:
197
168
first revision: %s
198
169
latest revision: %s
203
""" % (bound_tree._format.get_format_description(),
204
branch3._format.get_format_description(),
174
""" % (branch3.bzrdir.root_transport.base,
175
branch1.bzrdir.root_transport.base,
176
branch1.bzrdir.root_transport.base,
177
bound_tree._format.get_format_description(),
205
178
branch3.repository._format.get_format_description(),
206
179
datestring_first, datestring_first,
207
180
# poking at _revision_store isn't all that clean, but neither is
212
185
self.assertEqual('', err)
214
187
# Checkout standalone (same as above, but does not have parent set)
215
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)
217
192
branch4.bind(branch1)
218
193
branch4.bzrdir.open_workingtree().update()
219
out, err = self.run_bzr('info checkout --verbose')
194
out, err = self.runbzr('info checkout --verbose')
220
195
self.assertEqualDiff(
221
"""Checkout (format: knit)
223
checkout root: checkout
224
checkout of branch: standalone
198
checkout of branch: %s
227
201
control: Meta directory format 1
259
235
self.assertEqual('', err)
261
237
# Lightweight checkout (same as above, different branch and repository)
262
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)
263
246
branch5 = tree5.branch
264
out, err = self.run_bzr('info -v lightcheckout')
247
out, err = self.runbzr('info lightcheckout')
265
248
self.assertEqualDiff(
266
"""Lightweight checkout (format: dirstate or dirstate-tags)
268
light checkout root: lightcheckout
269
checkout of branch: standalone
250
light checkout root: %s
251
checkout of branch: %s
272
254
control: Meta directory format 1
273
working tree: Working tree format 4
255
working tree: Working tree format 3
274
256
branch: Branch format 4
275
257
repository: Weave repository format 6
338
320
first revision: %s
339
321
latest revision: %s
344
""" % (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,
346
331
self.assertEqual('', err)
348
333
# Out of date bound branch
349
out, err = self.run_bzr('info -v bound')
334
out, err = self.runbzr('info bound')
350
335
self.assertEqualDiff(
351
"""Checkout (format: knit)
354
checkout of branch: standalone
338
checkout of branch: %s
356
340
Related branches:
357
parent branch: standalone
360
344
control: Meta directory format 1
471
456
first revision: %s
472
457
latest revision: %s
477
""" % (datestring_first, datestring_last,), out)
462
""" % (tree5.bzrdir.root_transport.base,
463
branch1.bzrdir.root_transport.base,
464
datestring_first, datestring_last,
478
466
self.assertEqual('', err)
480
468
def test_info_standalone_no_tree(self):
481
469
# create standalone branch without a working tree
482
format = bzrdir.format_registry.make_bzrdir('default')
483
470
branch = self.make_branch('branch')
484
471
repo = branch.repository
485
out, err = self.run_bzr('info branch -v')
472
out, err = self.runbzr('info branch')
486
473
self.assertEqualDiff(
487
"""Standalone branch (format: dirstate-tags)
492
478
control: Meta directory format 1
479
branch: Branch format 5
503
""" % (format.get_branch_format().get_format_description(),
504
format.repository_format.get_format_description(),
488
""" % (branch.bzrdir.root_transport.base,
489
repo._format.get_format_description(),
506
491
self.assertEqual('', err)
508
493
def test_info_shared_repository(self):
509
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())
510
496
transport = self.get_transport()
512
498
# Create shared repository
513
repo = self.make_repository('repo', shared=True, format=format)
499
repo = self.make_repository('repo', shared=True)
514
500
repo.set_make_working_trees(False)
515
out, err = self.run_bzr('info -v repo')
501
out, err = self.runbzr('info repo')
516
502
self.assertEqualDiff(
517
"""Shared repository (format: dirstate or dirstate-tags or knit)
519
504
shared repository: %s
522
507
control: Meta directory format 1
528
""" % ('repo', format.repository_format.get_format_description(),
513
""" % (repo.bzrdir.root_transport.base,
514
repo._format.get_format_description(),
530
516
self.assertEqual('', err)
532
518
# Create branch inside shared repository
533
519
repo.bzrdir.root_transport.mkdir('branch')
534
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
536
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')
537
522
self.assertEqualDiff(
538
"""Repository branch (format: dirstate or knit)
540
shared repository: repo
541
repository branch: repo/branch
524
shared repository: %s
525
repository branch: branch
544
528
control: Meta directory format 1
529
branch: Branch format 5
555
""" % (format.get_branch_format().get_format_description(),
556
format.repository_format.get_format_description(),
538
""" % (repo.bzrdir.root_transport.base,
539
repo._format.get_format_description(),
558
541
self.assertEqual('', err)
560
543
# Create lightweight checkout
561
544
transport.mkdir('tree')
562
545
transport.mkdir('tree/lightcheckout')
563
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()
565
550
branch2 = tree2.branch
566
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
567
shared_repo=repo, repo_branch=branch1, verbose=True)
551
self.assertCheckoutStatusOutput('tree/lightcheckout', tree2, shared_repo=repo)
569
553
# Create normal checkout
570
554
tree3 = branch1.create_checkout('tree/checkout')
577
561
tree2.commit('commit one')
578
562
rev = repo.get_revision(branch2.revision_history()[0])
579
563
datestring_first = format_date(rev.timestamp, rev.timezone)
580
out, err = self.run_bzr('info tree/lightcheckout --verbose')
564
out, err = self.runbzr('info tree/lightcheckout --verbose')
581
565
self.assertEqualDiff(
582
"""Lightweight checkout (format: dirstate or dirstate-tags)
584
light checkout root: tree/lightcheckout
585
checkout of branch: repo/branch
586
shared repository: repo
567
light checkout root: %s
568
shared repository: %s
569
repository branch: branch
589
572
control: Meta directory format 1
590
working tree: Working tree format 4
573
working tree: Working tree format 3
574
branch: Branch format 5
594
577
In the working tree:
708
690
# Out of date lightweight checkout
709
691
rev = repo.get_revision(branch1.revision_history()[-1])
710
692
datestring_last = format_date(rev.timestamp, rev.timezone)
711
out, err = self.run_bzr('info tree/lightcheckout --verbose')
693
out, err = self.runbzr('info tree/lightcheckout --verbose')
712
694
self.assertEqualDiff(
713
"""Lightweight checkout (format: dirstate or dirstate-tags)
715
light checkout root: tree/lightcheckout
716
checkout of branch: repo/branch
717
shared repository: repo
696
light checkout root: %s
697
shared repository: %s
698
repository branch: branch
720
701
control: Meta directory format 1
721
working tree: Working tree format 4
702
working tree: Working tree format 3
703
branch: Branch format 5
725
706
Working tree is out of date: missing 1 revision.
786
767
self.assertEqual('', err)
788
769
# Show info about repository with revisions
789
out, err = self.run_bzr('info -v repo')
770
out, err = self.runbzr('info repo')
790
771
self.assertEqualDiff(
791
"""Shared repository (format: dirstate or dirstate-tags or knit)
793
shared repository: repo
773
shared repository: %s
796
776
control: Meta directory format 1
802
""" % (format.repository_format.get_format_description(),
782
""" % (repo.bzrdir.root_transport.base,
783
repo._format.get_format_description(),
803
784
# poking at _revision_store isn't all that clean, but neither is
804
785
# having the ui test dependent on the exact overhead of a given store.
805
786
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
807
788
self.assertEqual('', err)
790
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
809
792
def test_info_shared_repository_with_trees(self):
810
format = bzrdir.format_registry.make_bzrdir('knit')
793
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
794
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
811
795
transport = self.get_transport()
813
797
# Create shared repository with working trees
814
repo = self.make_repository('repo', shared=True, format=format)
798
repo = self.make_repository('repo', shared=True)
815
799
repo.set_make_working_trees(True)
816
out, err = self.run_bzr('info -v repo')
800
out, err = self.runbzr('info repo')
817
801
self.assertEqualDiff(
818
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
820
shared repository: repo
803
shared repository: %s
823
806
control: Meta directory format 1
826
809
Create working tree for new branches inside the repository.
831
""" % (format.repository_format.get_format_description(),
814
""" % (repo.bzrdir.root_transport.base,
815
repo._format.get_format_description(),
833
817
self.assertEqual('', err)
835
819
# Create two branches
836
820
repo.bzrdir.root_transport.mkdir('branch1')
837
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
821
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1')
839
822
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
841
824
# Empty first branch
842
out, err = self.run_bzr('info repo/branch1 --verbose')
825
out, err = self.runbzr('info repo/branch1 --verbose')
843
826
self.assertEqualDiff(
844
"""Repository tree (format: knit)
846
shared repository: repo
847
repository branch: repo/branch1
828
shared repository: %s
829
repository checkout: branch1
850
832
control: Meta directory format 1
851
833
working tree: Working tree format 3
834
branch: Branch format 5
855
837
In the working tree:
1027
1005
Create working tree for new branches inside the repository.
1032
""" % (format.repository_format.get_format_description(),
1010
""" % (repo.bzrdir.root_transport.base,
1011
repo._format.get_format_description(),
1033
1012
# poking at _revision_store isn't all that clean, but neither is
1034
1013
# having the ui test dependent on the exact overhead of a given store.
1035
1014
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1038
1017
self.assertEqual('', err)
1019
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1040
1021
def test_info_shared_repository_with_tree_in_root(self):
1041
format = bzrdir.format_registry.make_bzrdir('knit')
1022
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
1023
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
1042
1024
transport = self.get_transport()
1044
1026
# Create shared repository with working trees
1045
repo = self.make_repository('repo', shared=True, format=format)
1027
repo = self.make_repository('repo', shared=True)
1046
1028
repo.set_make_working_trees(True)
1047
out, err = self.run_bzr('info -v repo')
1029
out, err = self.runbzr('info repo')
1048
1030
self.assertEqualDiff(
1049
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1051
shared repository: repo
1032
shared repository: %s
1054
1035
control: Meta directory format 1
1093
1074
Branch history:
1100
""" % (format.get_branch_format().get_format_description(),
1101
format.repository_format.get_format_description(),
1080
""" % (repo.bzrdir.root_transport.base,
1081
repo._format.get_format_description(),
1103
1083
self.assertEqual('', err)
1085
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1105
1087
def assertCheckoutStatusOutput(self,
1106
1088
command_string, lco_tree, shared_repo=None,
1107
1089
repo_branch=None,
1108
1090
tree_locked=False,
1109
1091
branch_locked=False, repo_locked=False,
1111
light_checkout=True,
1112
checkout_root=None):
1113
"""Check the output of info in a checkout.
1093
light_checkout=True):
1094
"""Check the output of info in a light checkout tree.
1115
1096
This is not quite a mirror of the info code: rather than using the
1116
1097
tree being examined to predict output, it uses a bunch of flags which
1129
1110
:param repo_locked: If true, expect the repository to be locked.
1130
1111
:param verbose: If true, expect verbose output
1132
def friendly_location(url):
1133
path = urlutils.unescape_for_display(url, 'ascii')
1135
return osutils.relpath(osutils.getcwd(), path)
1136
except errors.PathNotChild:
1139
if tree_locked and sys.platform == 'win32':
1140
# We expect this to fail because of locking errors. (A write-locked
1141
# file cannot be read-locked in the same process).
1142
# This should be removed when the locking errors are fixed.
1143
self.run_bzr_error([], 'info ' + command_string)
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]
1113
out, err = self.runbzr('info %s' % command_string)
1154
1114
if repo_locked or branch_locked or tree_locked:
1155
1115
def locked_message(a_bool):
1168
1128
locked_message(repo_locked)))
1170
1130
expected_lock_output = ''
1173
1131
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)))
1132
tree_data = (" light checkout root: %s" %
1133
lco_tree.bzrdir.root_transport.base)
1135
tree_data = (" checkout root: %s" %
1136
lco_tree.bzrdir.root_transport.base)
1180
1137
if shared_repo is not None:
1181
1138
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)))
1139
" shared repository: %s\n"
1140
" repository branch: branch\n" %
1141
shared_repo.bzrdir.root_transport.base)
1186
1142
elif repo_branch is not None:
1187
1143
branch_data = (
1188
"%s checkout of branch: %s\n" %
1190
friendly_location(repo_branch.bzrdir.root_transport.base)))
1144
" checkout of branch: %s\n" %
1145
repo_branch.bzrdir.root_transport.base)
1192
branch_data = (" checkout of branch: %s\n" %
1147
branch_data = (" checkout of branch: %s\n" %
1193
1148
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)
1216
self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
1268
1218
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)
1220
self.assertCheckoutStatusOutput('tree/lightcheckout',
1274
1224
lco_tree.branch.repository.unlock()
1276
1226
lco_tree.branch.lock_write()
1278
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1228
self.assertCheckoutStatusOutput('tree/lightcheckout',
1280
1230
branch_locked=True,
1282
repo_branch=repo_branch,
1285
1233
lco_tree.branch.unlock()
1287
1235
lco_tree.lock_write()
1289
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1290
lco_tree, repo_branch=repo_branch,
1237
self.assertCheckoutStatusOutput('tree/lightcheckout',
1291
1239
tree_locked=True,
1292
1240
branch_locked=True,
1296
1243
lco_tree.unlock()
1298
1245
lco_tree.lock_write()
1299
1246
lco_tree.branch.repository.unlock()
1301
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1302
lco_tree, repo_branch=repo_branch,
1248
self.assertCheckoutStatusOutput('tree/lightcheckout',
1303
1250
tree_locked=True,
1307
1253
lco_tree.branch.repository.lock_write()
1308
1254
lco_tree.unlock()
1335
1279
lco_tree.branch.lock_write()
1336
1280
lco_tree.branch.repository.unlock()
1338
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1339
lco_tree, repo_branch=repo_branch,
1282
self.assertCheckoutStatusOutput('tree/lightcheckout',
1343
1286
lco_tree.branch.repository.lock_write()
1344
1287
lco_tree.branch.unlock()
1346
if sys.platform == 'win32':
1347
self.knownFailure('Win32 cannot run "bzr info"'
1348
' when the tree is locked.')
1350
1289
def test_info_locking_oslocks(self):
1351
1290
if sys.platform == "win32":
1352
1291
raise TestSkipped("don't use oslocks on win32 in unix manner")