~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_info.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-10-05 15:41:35 UTC
  • mfrom: (4725.2.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20091005154135-k407ea8ssyhayv10
(vila) Disambiguate per_transport test IDs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2008 Canonical Ltd
2
2
#
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
25
25
    errors,
26
26
    info,
27
27
    osutils,
28
 
    tests,
29
28
    upgrade,
30
29
    urlutils,
31
30
    )
32
 
from bzrlib.transport import memory
33
 
 
34
 
 
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
 
34
 
 
35
 
 
36
class TestInfo(ExternalBase):
36
37
 
37
38
    def setUp(self):
38
 
        super(TestInfo, self).setUp()
39
 
        self._repo_strings = "2a"
 
39
        ExternalBase.setUp(self)
 
40
        self._repo_strings = "2a or development-subtree"
40
41
 
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()
50
51
 
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'])
54
55
        tree1.add('a')
55
56
        branch1 = tree1.branch
56
57
 
57
58
        out, err = self.run_bzr('info standalone')
58
59
        self.assertEqualDiff(
59
 
"""Standalone tree (format: knit)
 
60
"""Standalone tree (format: weave)
60
61
Location:
61
62
  branch root: standalone
62
63
""", out)
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)
69
70
Location:
70
71
  branch root: standalone
71
72
 
72
73
Format:
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
77
78
 
78
79
In the working tree:
79
80
         0 unchanged
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)
100
101
Location:
101
102
  branch root: standalone
102
103
 
103
104
Format:
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
108
109
 
109
110
In the working tree:
110
111
         0 unchanged
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)
130
131
 
131
132
        # Branch standalone with push location
132
133
        branch2 = branch1.bzrdir.sprout('branch').open_branch()
134
135
 
135
136
        out, err = self.run_bzr('info branch')
136
137
        self.assertEqualDiff(
137
 
"""Standalone tree (format: knit)
 
138
"""Standalone tree (format: weave)
138
139
Location:
139
140
  branch root: branch
140
141
 
146
147
 
147
148
        out, err = self.run_bzr('info branch --verbose')
148
149
        self.assertEqualDiff(
149
 
"""Standalone tree (format: knit)
 
150
"""Standalone tree (format: weave)
150
151
Location:
151
152
  branch root: branch
152
153
 
155
156
  parent branch: standalone
156
157
 
157
158
Format:
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
162
163
 
163
164
In the working tree:
164
165
         1 unchanged
212
213
         0 added
213
214
         0 removed
214
215
         0 renamed
215
 
         0 unknown
 
216
         1 unknown
216
217
         0 ignored
217
218
         0 versioned subdirectories
218
219
 
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"
281
 
        else:
282
 
            format_description = "knit"
283
280
        self.assertEqualDiff(
284
281
"""Lightweight checkout (format: %s)
285
282
Location:
288
285
 
289
286
Format:
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
294
291
 
295
292
In the working tree:
296
293
         1 unchanged
310
307
 
311
308
Repository:
312
309
         1 revision
313
 
""" % (format_description, datestring_first, datestring_first,), out)
 
310
""" % (self._repo_strings, datestring_first, datestring_first,), out)
314
311
        self.assertEqual('', err)
315
312
 
316
313
        # Update initial standalone branch
318
315
        tree1.add('b')
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)
322
319
 
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)
327
324
Location:
328
325
  branch root: branch
329
326
 
332
329
  parent branch: standalone
333
330
 
334
331
Format:
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
339
336
 
340
337
In the working tree:
341
338
         1 unchanged
384
381
         0 added
385
382
         0 removed
386
383
         0 renamed
387
 
         0 unknown
 
384
         1 unknown
388
385
         0 ignored
389
386
         0 versioned subdirectories
390
387
 
450
447
 
451
448
Format:
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
456
453
 
457
454
Working tree is out of date: missing 1 revision.
458
455
 
474
471
 
475
472
Repository:
476
473
         2 revisions
477
 
""" % (format_description, datestring_first, datestring_last,), out)
 
474
""" % (self._repo_strings, datestring_first, datestring_last,), out)
478
475
        self.assertEqual('', err)
479
476
 
480
477
    def test_info_standalone_no_tree(self):
572
569
        tree2.add('a')
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)
691
688
 
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)
847
844
        tree1.add('a')
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()
1239
1235
 
1327
1323
            self.knownFailure('Win32 cannot run "bzr info"'
1328
1324
                              ' when the tree is locked.')
1329
1325
 
 
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
 
1332
        # call here.
 
1333
        self.thisFailsStrictLockCheck()
 
1334
 
 
1335
        tree = self.make_branch_and_tree('branch',
 
1336
                                         format=bzrdir.BzrDirFormat6())
 
1337
 
 
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)
 
1342
        # W B R
 
1343
 
 
1344
        # U U U
 
1345
        out, err = self.run_bzr('info -v branch')
 
1346
        self.assertEqualDiff(
 
1347
"""Standalone tree (format: weave)
 
1348
Location:
 
1349
  branch root: %s
 
1350
 
 
1351
Format:
 
1352
       control: All-in-one format 6
 
1353
  working tree: Working tree format 2
 
1354
        branch: Branch format 4
 
1355
    repository: %s
 
1356
 
 
1357
In the working tree:
 
1358
         0 unchanged
 
1359
         0 modified
 
1360
         0 added
 
1361
         0 removed
 
1362
         0 renamed
 
1363
         0 unknown
 
1364
         0 ignored
 
1365
         0 versioned subdirectories
 
1366
 
 
1367
Branch history:
 
1368
         0 revisions
 
1369
 
 
1370
Repository:
 
1371
         0 revisions
 
1372
""" % ('branch', tree.branch.repository._format.get_format_description(),
 
1373
       ), out)
 
1374
        self.assertEqual('', err)
 
1375
        # L L L
 
1376
        tree.lock_write()
 
1377
        out, err = self.run_bzr('info -v branch')
 
1378
        self.assertEqualDiff(
 
1379
"""Standalone tree (format: weave)
 
1380
Location:
 
1381
  branch root: %s
 
1382
 
 
1383
Format:
 
1384
       control: All-in-one format 6
 
1385
  working tree: Working tree format 2
 
1386
        branch: Branch format 4
 
1387
    repository: %s
 
1388
 
 
1389
In the working tree:
 
1390
         0 unchanged
 
1391
         0 modified
 
1392
         0 added
 
1393
         0 removed
 
1394
         0 renamed
 
1395
         0 unknown
 
1396
         0 ignored
 
1397
         0 versioned subdirectories
 
1398
 
 
1399
Branch history:
 
1400
         0 revisions
 
1401
 
 
1402
Repository:
 
1403
         0 revisions
 
1404
""" % ('branch', tree.branch.repository._format.get_format_description(),
 
1405
       ), out)
 
1406
        self.assertEqual('', err)
 
1407
        tree.unlock()
 
1408
 
1330
1409
    def test_info_stacked(self):
1331
1410
        # We have a mainline
1332
1411
        trunk_tree = self.make_branch_and_tree('mainline',