41
34
location = "C:/i/do/not/exist/"
43
36
location = "/i/do/not/exist/"
44
out, err = self.run_bzr('info '+location, retcode=3)
37
out, err = self.runbzr('info '+location, retcode=3)
45
38
self.assertEqual(out, '')
46
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
39
self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
48
41
def test_info_standalone(self):
49
42
transport = self.get_transport()
51
44
# Create initial standalone branch
52
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)
53
49
self.build_tree(['standalone/a'])
55
51
branch1 = tree1.branch
57
out, err = self.run_bzr('info standalone')
59
"""Standalone tree (format: weave)
61
branch root: standalone
63
self.assertEqual('', err)
65
out, err = self.run_bzr('info standalone -v')
67
"""Standalone tree (format: weave)
69
branch root: standalone
52
out, err = self.runbzr('info standalone')
72
58
control: All-in-one format 6
100
85
# Branch standalone with push location
101
86
branch2 = branch1.bzrdir.sprout('branch').open_branch()
102
87
branch2.set_push_location(branch1.bzrdir.root_transport.base)
104
out, err = self.run_bzr('info branch')
105
self.assertEqualDiff(
106
"""Standalone tree (format: weave)
111
push branch: standalone
112
parent branch: standalone
114
self.assertEqual('', err)
116
out, err = self.run_bzr('info branch --verbose')
117
self.assertEqualDiff(
118
"""Standalone tree (format: weave)
123
push branch: standalone
124
parent branch: standalone
88
out, err = self.runbzr('info branch --verbose')
127
98
control: All-in-one format 6
160
134
# Branch and bind to standalone, needs upgrade to metadir
161
135
# (creates backup as unknown)
162
136
branch1.bzrdir.sprout('bound')
163
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
137
knit1_format = bzrlib.bzrdir.BzrDirMetaFormat1()
138
knit1_format.repository_format = repository.RepositoryFormatKnit1()
164
139
bzrlib.upgrade.upgrade('bound', knit1_format)
165
140
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
166
141
branch3.bind(branch1)
167
142
bound_tree = branch3.bzrdir.open_workingtree()
168
out, err = self.run_bzr('info -v bound')
143
out, err = self.runbzr('info bound')
169
144
self.assertEqualDiff(
170
"""Checkout (format: knit)
173
checkout of branch: standalone
147
checkout of branch: %s
175
149
Related branches:
176
parent branch: standalone
179
153
control: Meta directory format 1
155
branch: Branch format 5
184
158
In the working tree:
198
171
first revision: %s
199
172
latest revision: %s
204
""" % (bound_tree._format.get_format_description(),
205
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(),
206
181
branch3.repository._format.get_format_description(),
207
182
datestring_first, datestring_first,
208
183
# poking at _revision_store isn't all that clean, but neither is
213
188
self.assertEqual('', err)
215
190
# Checkout standalone (same as above, but does not have parent set)
216
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)
218
195
branch4.bind(branch1)
219
196
branch4.bzrdir.open_workingtree().update()
220
out, err = self.run_bzr('info checkout --verbose')
197
out, err = self.runbzr('info checkout --verbose')
221
198
self.assertEqualDiff(
222
"""Checkout (format: knit)
224
checkout root: checkout
225
checkout of branch: standalone
201
checkout of branch: %s
228
204
control: Meta directory format 1
260
238
self.assertEqual('', err)
262
240
# Lightweight checkout (same as above, different branch and repository)
263
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)
264
249
branch5 = tree5.branch
265
out, err = self.run_bzr('info -v lightcheckout')
250
out, err = self.runbzr('info lightcheckout')
266
251
self.assertEqualDiff(
267
"""Lightweight checkout (format: dirstate or dirstate-tags or \
268
pack-0.92 or rich-root or rich-root-pack)
270
light checkout root: lightcheckout
271
checkout of branch: standalone
253
light checkout root: %s
254
checkout of branch: %s
274
257
control: Meta directory format 1
275
working tree: Working tree format 4
258
working tree: Working tree format 3
276
259
branch: Branch format 4
277
260
repository: Weave repository format 6
340
323
first revision: %s
341
324
latest revision: %s
346
""" % (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,
348
334
self.assertEqual('', err)
350
336
# Out of date bound branch
351
out, err = self.run_bzr('info -v bound')
337
out, err = self.runbzr('info bound')
352
338
self.assertEqualDiff(
353
"""Checkout (format: knit)
356
checkout of branch: standalone
341
checkout of branch: %s
358
343
Related branches:
359
parent branch: standalone
362
347
control: Meta directory format 1
441
428
self.assertEqual('', err)
443
430
# Out of date lightweight checkout
444
out, err = self.run_bzr('info lightcheckout --verbose')
431
out, err = self.runbzr('info lightcheckout --verbose')
445
432
self.assertEqualDiff(
446
"""Lightweight checkout (format: dirstate or dirstate-tags or \
447
pack-0.92 or rich-root or rich-root-pack)
449
light checkout root: lightcheckout
450
checkout of branch: standalone
434
light checkout root: %s
435
checkout of branch: %s
453
438
control: Meta directory format 1
454
working tree: Working tree format 4
439
working tree: Working tree format 3
455
440
branch: Branch format 4
456
441
repository: Weave repository format 6
474
459
first revision: %s
475
460
latest revision: %s
480
""" % (datestring_first, datestring_last,), out)
465
""" % (tree5.bzrdir.root_transport.base,
466
branch1.bzrdir.root_transport.base,
467
datestring_first, datestring_last,
481
469
self.assertEqual('', err)
483
471
def test_info_standalone_no_tree(self):
484
472
# create standalone branch without a working tree
485
format = bzrdir.format_registry.make_bzrdir('default')
486
473
branch = self.make_branch('branch')
487
474
repo = branch.repository
488
out, err = self.run_bzr('info branch -v')
475
out, err = self.runbzr('info branch')
489
476
self.assertEqualDiff(
490
"""Standalone branch (format: %s)
495
481
control: Meta directory format 1
482
branch: Branch format 5
506
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
507
format.get_branch_format().get_format_description(),
508
format.repository_format.get_format_description(),
491
""" % (branch.bzrdir.root_transport.base,
492
repo._format.get_format_description(),
510
494
self.assertEqual('', err)
512
496
def test_info_shared_repository(self):
513
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())
514
499
transport = self.get_transport()
516
501
# Create shared repository
517
repo = self.make_repository('repo', shared=True, format=format)
502
repo = self.make_repository('repo', shared=True)
518
503
repo.set_make_working_trees(False)
519
out, err = self.run_bzr('info -v repo')
504
out, err = self.runbzr('info repo')
520
505
self.assertEqualDiff(
521
"""Shared repository (format: dirstate or dirstate-tags or knit)
523
507
shared repository: %s
526
510
control: Meta directory format 1
532
""" % ('repo', format.repository_format.get_format_description(),
516
""" % (repo.bzrdir.root_transport.base,
517
repo._format.get_format_description(),
534
519
self.assertEqual('', err)
536
521
# Create branch inside shared repository
537
522
repo.bzrdir.root_transport.mkdir('branch')
538
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
540
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')
541
525
self.assertEqualDiff(
542
"""Repository branch (format: dirstate or knit)
544
shared repository: repo
545
repository branch: repo/branch
527
shared repository: %s
528
repository branch: branch
548
531
control: Meta directory format 1
532
branch: Branch format 5
559
""" % (format.get_branch_format().get_format_description(),
560
format.repository_format.get_format_description(),
541
""" % (repo.bzrdir.root_transport.base,
542
repo._format.get_format_description(),
562
544
self.assertEqual('', err)
564
546
# Create lightweight checkout
565
547
transport.mkdir('tree')
566
548
transport.mkdir('tree/lightcheckout')
567
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()
569
553
branch2 = tree2.branch
570
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
571
shared_repo=repo, repo_branch=branch1, verbose=True)
554
self.assertCheckoutStatusOutput('tree/lightcheckout', tree2, shared_repo=repo)
573
556
# Create normal checkout
574
557
tree3 = branch1.create_checkout('tree/checkout')
581
564
tree2.commit('commit one')
582
565
rev = repo.get_revision(branch2.revision_history()[0])
583
566
datestring_first = format_date(rev.timestamp, rev.timezone)
584
out, err = self.run_bzr('info tree/lightcheckout --verbose')
567
out, err = self.runbzr('info tree/lightcheckout --verbose')
585
568
self.assertEqualDiff(
586
"""Lightweight checkout (format: dirstate or dirstate-tags or \
587
pack-0.92 or rich-root or rich-root-pack)
589
light checkout root: tree/lightcheckout
590
checkout of branch: repo/branch
591
shared repository: repo
570
light checkout root: %s
571
shared repository: %s
572
repository branch: branch
594
575
control: Meta directory format 1
595
working tree: Working tree format 4
576
working tree: Working tree format 3
577
branch: Branch format 5
599
580
In the working tree:
713
693
# Out of date lightweight checkout
714
694
rev = repo.get_revision(branch1.revision_history()[-1])
715
695
datestring_last = format_date(rev.timestamp, rev.timezone)
716
out, err = self.run_bzr('info tree/lightcheckout --verbose')
696
out, err = self.runbzr('info tree/lightcheckout --verbose')
717
697
self.assertEqualDiff(
718
"""Lightweight checkout (format: dirstate or dirstate-tags or \
719
pack-0.92 or rich-root or rich-root-pack)
721
light checkout root: tree/lightcheckout
722
checkout of branch: repo/branch
723
shared repository: repo
699
light checkout root: %s
700
shared repository: %s
701
repository branch: branch
726
704
control: Meta directory format 1
727
working tree: Working tree format 4
705
working tree: Working tree format 3
706
branch: Branch format 5
731
709
Working tree is out of date: missing 1 revision.
792
770
self.assertEqual('', err)
794
772
# Show info about repository with revisions
795
out, err = self.run_bzr('info -v repo')
773
out, err = self.runbzr('info repo')
796
774
self.assertEqualDiff(
797
"""Shared repository (format: dirstate or dirstate-tags or knit)
799
shared repository: repo
776
shared repository: %s
802
779
control: Meta directory format 1
808
""" % (format.repository_format.get_format_description(),
785
""" % (repo.bzrdir.root_transport.base,
786
repo._format.get_format_description(),
809
787
# poking at _revision_store isn't all that clean, but neither is
810
788
# having the ui test dependent on the exact overhead of a given store.
811
789
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
813
791
self.assertEqual('', err)
793
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
815
795
def test_info_shared_repository_with_trees(self):
816
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())
817
798
transport = self.get_transport()
819
800
# Create shared repository with working trees
820
repo = self.make_repository('repo', shared=True, format=format)
801
repo = self.make_repository('repo', shared=True)
821
802
repo.set_make_working_trees(True)
822
out, err = self.run_bzr('info -v repo')
803
out, err = self.runbzr('info repo')
823
804
self.assertEqualDiff(
824
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
826
shared repository: repo
806
shared repository: %s
829
809
control: Meta directory format 1
832
812
Create working tree for new branches inside the repository.
837
""" % (format.repository_format.get_format_description(),
817
""" % (repo.bzrdir.root_transport.base,
818
repo._format.get_format_description(),
839
820
self.assertEqual('', err)
841
822
# Create two branches
842
823
repo.bzrdir.root_transport.mkdir('branch1')
843
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
824
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1')
845
825
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
847
827
# Empty first branch
848
out, err = self.run_bzr('info repo/branch1 --verbose')
828
out, err = self.runbzr('info repo/branch1 --verbose')
849
829
self.assertEqualDiff(
850
"""Repository tree (format: knit)
852
shared repository: repo
853
repository branch: repo/branch1
831
shared repository: %s
832
repository checkout: branch1
856
835
control: Meta directory format 1
857
836
working tree: Working tree format 3
837
branch: Branch format 5
861
840
In the working tree:
1033
1008
Create working tree for new branches inside the repository.
1038
""" % (format.repository_format.get_format_description(),
1013
""" % (repo.bzrdir.root_transport.base,
1014
repo._format.get_format_description(),
1039
1015
# poking at _revision_store isn't all that clean, but neither is
1040
1016
# having the ui test dependent on the exact overhead of a given store.
1041
1017
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1044
1020
self.assertEqual('', err)
1022
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1046
1024
def test_info_shared_repository_with_tree_in_root(self):
1047
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())
1048
1027
transport = self.get_transport()
1050
1029
# Create shared repository with working trees
1051
repo = self.make_repository('repo', shared=True, format=format)
1030
repo = self.make_repository('repo', shared=True)
1052
1031
repo.set_make_working_trees(True)
1053
out, err = self.run_bzr('info -v repo')
1032
out, err = self.runbzr('info repo')
1054
1033
self.assertEqualDiff(
1055
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1057
shared repository: repo
1035
shared repository: %s
1060
1038
control: Meta directory format 1
1099
1077
Branch history:
1106
""" % (format.get_branch_format().get_format_description(),
1107
format.repository_format.get_format_description(),
1083
""" % (repo.bzrdir.root_transport.base,
1084
repo._format.get_format_description(),
1109
1086
self.assertEqual('', err)
1111
def assertCheckoutStatusOutput(self,
1088
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1090
def assertCheckoutStatusOutput(self,
1112
1091
command_string, lco_tree, shared_repo=None,
1113
1092
repo_branch=None,
1114
1093
tree_locked=False,
1115
1094
branch_locked=False, repo_locked=False,
1117
light_checkout=True,
1118
checkout_root=None):
1119
"""Check the output of info in a checkout.
1096
light_checkout=True):
1097
"""Check the output of info in a light checkout tree.
1121
1099
This is not quite a mirror of the info code: rather than using the
1122
1100
tree being examined to predict output, it uses a bunch of flags which
1133
1111
:param tree_locked: If true, expect the tree to be locked.
1134
1112
:param branch_locked: If true, expect the branch to be locked.
1135
1113
:param repo_locked: If true, expect the repository to be locked.
1136
Note that the lco_tree.branch.repository is inspected, and if is not
1137
actually locked then this parameter is overridden. This is because
1138
pack repositories do not have any public API for obtaining an
1139
exclusive repository wide lock.
1140
1114
:param verbose: If true, expect verbose output
1142
def friendly_location(url):
1143
path = urlutils.unescape_for_display(url, 'ascii')
1145
return osutils.relpath(osutils.getcwd(), path)
1146
except errors.PathNotChild:
1150
# We expect this to fail because of locking errors.
1151
# (A write-locked file cannot be read-locked
1152
# in the different process -- either on win32 or on linux).
1153
# This should be removed when the locking errors are fixed.
1154
self.expectFailure('OS locks are exclusive '
1155
'for different processes (Bug #174055)',
1156
self.run_bzr_subprocess,
1157
'info ' + command_string)
1158
out, err = self.run_bzr('info %s' % command_string)
1160
(True, True): 'Lightweight checkout',
1161
(True, False): 'Repository checkout',
1162
(False, True): 'Lightweight checkout',
1163
(False, False): 'Checkout',
1164
}[(shared_repo is not None, light_checkout)]
1165
format = {True: 'dirstate or dirstate-tags or pack-0.92'
1166
' or rich-root or rich-root-pack',
1167
False: 'dirstate'}[light_checkout]
1169
repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1116
out, err = self.runbzr('info %s' % command_string)
1170
1117
if repo_locked or branch_locked or tree_locked:
1171
1118
def locked_message(a_bool):
1184
1131
locked_message(repo_locked)))
1186
1133
expected_lock_output = ''
1189
1134
if light_checkout:
1190
tree_data = (" light checkout root: %s\n" %
1191
friendly_location(lco_tree.bzrdir.root_transport.base))
1193
if lco_tree.branch.get_bound_location() is not None:
1194
tree_data += ("%s checkout root: %s\n" % (extra_space,
1195
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)
1196
1140
if shared_repo is not None:
1197
1141
branch_data = (
1198
" checkout of branch: %s\n"
1199
" shared repository: %s\n" %
1200
(friendly_location(repo_branch.bzrdir.root_transport.base),
1201
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)
1202
1145
elif repo_branch is not None:
1203
1146
branch_data = (
1204
"%s checkout of branch: %s\n" %
1206
friendly_location(repo_branch.bzrdir.root_transport.base)))
1147
" checkout of branch: %s\n" %
1148
repo_branch.bzrdir.root_transport.base)
1208
branch_data = (" checkout of branch: %s\n" %
1150
branch_data = (" checkout of branch: %s\n" %
1209
1151
lco_tree.branch.bzrdir.root_transport.base)
1280
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1281
repo_branch=repo_branch,
1282
verbose=True, light_checkout=True)
1219
self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
1284
1221
lco_tree.branch.repository.lock_write()
1286
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1287
lco_tree, repo_branch=repo_branch,
1288
repo_locked=True, verbose=True, light_checkout=True)
1223
self.assertCheckoutStatusOutput('tree/lightcheckout',
1290
1227
lco_tree.branch.repository.unlock()
1292
1229
lco_tree.branch.lock_write()
1294
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1231
self.assertCheckoutStatusOutput('tree/lightcheckout',
1296
1233
branch_locked=True,
1298
repo_branch=repo_branch,
1301
1236
lco_tree.branch.unlock()
1303
1238
lco_tree.lock_write()
1305
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1306
lco_tree, repo_branch=repo_branch,
1240
self.assertCheckoutStatusOutput('tree/lightcheckout',
1307
1242
tree_locked=True,
1308
1243
branch_locked=True,
1312
1246
lco_tree.unlock()
1314
1248
lco_tree.lock_write()
1315
1249
lco_tree.branch.repository.unlock()
1317
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1318
lco_tree, repo_branch=repo_branch,
1251
self.assertCheckoutStatusOutput('tree/lightcheckout',
1319
1253
tree_locked=True,
1323
1256
lco_tree.branch.repository.lock_write()
1324
1257
lco_tree.unlock()
1351
1282
lco_tree.branch.lock_write()
1352
1283
lco_tree.branch.repository.unlock()
1354
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1355
lco_tree, repo_branch=repo_branch,
1285
self.assertCheckoutStatusOutput('tree/lightcheckout',
1359
1289
lco_tree.branch.repository.lock_write()
1360
1290
lco_tree.branch.unlock()
1362
if sys.platform == 'win32':
1363
self.knownFailure('Win32 cannot run "bzr info"'
1364
' when the tree is locked.')
1366
1292
def test_info_locking_oslocks(self):
1367
1293
if sys.platform == "win32":
1368
1294
raise TestSkipped("don't use oslocks on win32 in unix manner")