1
# Copyright (C) 2006-2010 Canonical Ltd
1
# Copyright (C) 2006, 2007, 2008 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
32
from bzrlib.transport import memory
35
class TestInfo(tests.TestCaseWithTransport):
31
from bzrlib.osutils import format_date
32
from bzrlib.tests import TestSkipped, MemoryServer
33
from bzrlib.tests.blackbox import ExternalBase
36
class TestInfo(ExternalBase):
38
super(TestInfo, self).setUp()
39
self._repo_strings = "2a"
39
ExternalBase.setUp(self)
40
self._repo_strings = "2a or development-subtree"
41
42
def test_info_non_existing(self):
42
self.vfs_transport_factory = memory.MemoryServer
43
self.vfs_transport_factory = MemoryServer
43
44
location = self.get_url()
44
45
out, err = self.run_bzr('info '+location, retcode=3)
45
46
self.assertEqual(out, '')
49
50
transport = self.get_transport()
51
52
# Create initial standalone branch
52
tree1 = self.make_branch_and_tree('standalone', 'knit')
53
tree1 = self.make_branch_and_tree('standalone', 'weave')
53
54
self.build_tree(['standalone/a'])
55
56
branch1 = tree1.branch
57
58
out, err = self.run_bzr('info standalone')
58
59
self.assertEqualDiff(
59
"""Standalone tree (format: knit)
60
"""Standalone tree (format: weave)
61
62
branch root: standalone
65
66
# Standalone branch - verbose mode
66
67
out, err = self.run_bzr('info standalone -v')
67
68
self.assertEqualDiff(
68
"""Standalone tree (format: knit)
69
"""Standalone tree (format: weave)
70
71
branch root: standalone
73
control: Meta directory format 1
74
working tree: Working tree format 3
75
branch: Branch format 5
76
repository: Knit repository format 1
74
control: All-in-one format 6
75
working tree: Working tree format 2
76
branch: Branch format 4
77
repository: Weave repository format 6
78
79
In the working tree:
96
97
# Standalone branch - really verbose mode
97
98
out, err = self.run_bzr('info standalone -vv')
98
99
self.assertEqualDiff(
99
"""Standalone tree (format: knit)
100
"""Standalone tree (format: weave)
101
102
branch root: standalone
104
control: Meta directory format 1
105
working tree: Working tree format 3
106
branch: Branch format 5
107
repository: Knit repository format 1
105
control: All-in-one format 6
106
working tree: Working tree format 2
107
branch: Branch format 4
108
repository: Weave repository format 6
109
110
In the working tree:
126
127
self.assertEqual('', err)
127
128
tree1.commit('commit one')
128
129
rev = branch1.repository.get_revision(branch1.revision_history()[0])
129
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
130
datestring_first = format_date(rev.timestamp, rev.timezone)
131
132
# Branch standalone with push location
132
133
branch2 = branch1.bzrdir.sprout('branch').open_branch()
155
156
parent branch: standalone
158
control: Meta directory format 1
159
working tree: Working tree format 3
160
branch: Branch format 5
161
repository: Knit repository format 1
159
control: All-in-one format 6
160
working tree: Working tree format 2
161
branch: Branch format 4
162
repository: Weave repository format 6
163
164
In the working tree:
276
277
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
277
278
branch5 = tree5.branch
278
279
out, err = self.run_bzr('info -v lightcheckout')
279
if "metaweave" in bzrdir.format_registry:
280
format_description = "knit or metaweave"
282
format_description = "knit"
283
280
self.assertEqualDiff(
284
281
"""Lightweight checkout (format: %s)
290
287
control: Meta directory format 1
291
working tree: Working tree format 3
292
branch: Branch format 5
293
repository: Knit repository format 1
288
working tree: Working tree format 6
289
branch: Branch format 4
290
repository: Weave repository format 6
295
292
In the working tree:
313
""" % (format_description, datestring_first, datestring_first,), out)
310
""" % (self._repo_strings, datestring_first, datestring_first,), out)
314
311
self.assertEqual('', err)
316
313
# Update initial standalone branch
319
316
tree1.commit('commit two')
320
317
rev = branch1.repository.get_revision(branch1.revision_history()[-1])
321
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
318
datestring_last = format_date(rev.timestamp, rev.timezone)
323
320
# Out of date branched standalone branch will not be detected
324
321
out, err = self.run_bzr('info -v branch')
325
322
self.assertEqualDiff(
326
"""Standalone tree (format: knit)
323
"""Standalone tree (format: weave)
328
325
branch root: branch
332
329
parent branch: standalone
335
control: Meta directory format 1
336
working tree: Working tree format 3
337
branch: Branch format 5
338
repository: Knit repository format 1
332
control: All-in-one format 6
333
working tree: Working tree format 2
334
branch: Branch format 4
335
repository: Weave repository format 6
340
337
In the working tree:
452
449
control: Meta directory format 1
453
working tree: Working tree format 3
454
branch: Branch format 5
455
repository: Knit repository format 1
450
working tree: Working tree format 6
451
branch: Branch format 4
452
repository: Weave repository format 6
457
454
Working tree is out of date: missing 1 revision.
477
""" % (format_description, datestring_first, datestring_last,), out)
474
""" % (self._repo_strings, datestring_first, datestring_last,), out)
478
475
self.assertEqual('', err)
480
477
def test_info_standalone_no_tree(self):
573
570
tree2.commit('commit one')
574
571
rev = repo.get_revision(branch2.revision_history()[0])
575
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
572
datestring_first = format_date(rev.timestamp, rev.timezone)
576
573
out, err = self.run_bzr('info tree/lightcheckout --verbose')
577
574
self.assertEqualDiff(
578
575
"""Lightweight checkout (format: %s)
692
689
# Out of date lightweight checkout
693
690
rev = repo.get_revision(branch1.revision_history()[-1])
694
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
691
datestring_last = format_date(rev.timestamp, rev.timezone)
695
692
out, err = self.run_bzr('info tree/lightcheckout --verbose')
696
693
self.assertEqualDiff(
697
694
"""Lightweight checkout (format: %s)
848
845
tree1.commit('commit one')
849
846
rev = repo.get_revision(branch1.revision_history()[0])
850
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
847
datestring_first = format_date(rev.timestamp, rev.timezone)
851
848
out, err = self.run_bzr('info -v repo/branch1')
852
849
self.assertEqualDiff(
853
850
"""Repository tree (format: knit)
1232
1229
# Do a light checkout of the heavy one
1233
1230
transport.mkdir('tree/lightcheckout')
1234
1231
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1235
branch.BranchReferenceFormat().initialize(lco_dir,
1236
target_branch=co_branch)
1232
branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1237
1233
lco_dir.create_workingtree()
1238
1234
lco_tree = lco_dir.open_workingtree()
1327
1323
self.knownFailure('Win32 cannot run "bzr info"'
1328
1324
' when the tree is locked.')
1326
def test_info_locking_oslocks(self):
1327
if sys.platform == "win32":
1328
raise TestSkipped("don't use oslocks on win32 in unix manner")
1329
# This test tests old (all-in-one, OS lock using) behaviour which
1330
# simply cannot work on windows (and is indeed why we changed our
1331
# design. As such, don't try to remove the thisFailsStrictLockCheck
1333
self.thisFailsStrictLockCheck()
1335
tree = self.make_branch_and_tree('branch',
1336
format=bzrdir.BzrDirFormat6())
1338
# Test all permutations of locking the working tree, branch and repository
1339
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1340
# implemented by raising NotImplementedError and get_physical_lock_status()
1341
# always returns false. This makes bzr info hide the lock status. (Olaf)
1345
out, err = self.run_bzr('info -v branch')
1346
self.assertEqualDiff(
1347
"""Standalone tree (format: weave)
1352
control: All-in-one format 6
1353
working tree: Working tree format 2
1354
branch: Branch format 4
1357
In the working tree:
1365
0 versioned subdirectories
1372
""" % ('branch', tree.branch.repository._format.get_format_description(),
1374
self.assertEqual('', err)
1377
out, err = self.run_bzr('info -v branch')
1378
self.assertEqualDiff(
1379
"""Standalone tree (format: weave)
1384
control: All-in-one format 6
1385
working tree: Working tree format 2
1386
branch: Branch format 4
1389
In the working tree:
1397
0 versioned subdirectories
1404
""" % ('branch', tree.branch.repository._format.get_format_description(),
1406
self.assertEqual('', err)
1330
1409
def test_info_stacked(self):
1331
1410
# We have a mainline
1332
1411
trunk_tree = self.make_branch_and_tree('mainline',