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