/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Lawrence Mitchell
  • Date: 2011-11-08 10:54:09 UTC
  • mto: This revision was merged to the branch mainline in revision 6245.
  • Revision ID: wence@gmx.li-20111108105409-cgdqeek7vl7e8nbb
Only set check_clean if {clean} is asked for in template
      
The {clean} flag in templates requires an lstat of every file in the
repository.  If the filesystem is slow this can take a noticeable
amount of time.  So only switch check_clean to True if the template
actually asks for it, to avoid penalising those who don't want to
know.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from bzrlib import (
23
23
    branch,
24
24
    bzrdir,
 
25
    controldir,
25
26
    errors,
26
27
    info,
27
28
    osutils,
49
50
        transport = self.get_transport()
50
51
 
51
52
        # Create initial standalone branch
52
 
        tree1 = self.make_branch_and_tree('standalone', 'weave')
 
53
        tree1 = self.make_branch_and_tree('standalone', 'knit')
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: weave)
 
60
"""Standalone tree (format: knit)
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: weave)
 
69
"""Standalone tree (format: knit)
69
70
Location:
70
71
  branch root: standalone
71
72
 
72
73
Format:
73
 
       control: All-in-one format 6
74
 
  working tree: Working tree format 2
75
 
        branch: Branch format 4
76
 
    repository: Weave repository format 6
 
74
       control: Meta directory format 1
 
75
  working tree: Working tree format 3
 
76
        branch: Branch format 5
 
77
    repository: Knit repository format 1
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: weave)
 
100
"""Standalone tree (format: knit)
100
101
Location:
101
102
  branch root: standalone
102
103
 
103
104
Format:
104
 
       control: All-in-one format 6
105
 
  working tree: Working tree format 2
106
 
        branch: Branch format 4
107
 
    repository: Weave repository format 6
 
105
       control: Meta directory format 1
 
106
  working tree: Working tree format 3
 
107
        branch: Branch format 5
 
108
    repository: Knit repository format 1
108
109
 
109
110
In the working tree:
110
111
         0 unchanged
125
126
""", out)
126
127
        self.assertEqual('', err)
127
128
        tree1.commit('commit one')
128
 
        rev = branch1.repository.get_revision(branch1.revision_history()[0])
 
129
        rev = branch1.repository.get_revision(branch1.last_revision())
129
130
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
130
131
 
131
132
        # Branch standalone with push location
134
135
 
135
136
        out, err = self.run_bzr('info branch')
136
137
        self.assertEqualDiff(
137
 
"""Standalone tree (format: weave)
 
138
"""Standalone tree (format: knit)
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: weave)
 
150
"""Standalone tree (format: knit)
150
151
Location:
151
152
  branch root: branch
152
153
 
155
156
  parent branch: standalone
156
157
 
157
158
Format:
158
 
       control: All-in-one format 6
159
 
  working tree: Working tree format 2
160
 
        branch: Branch format 4
161
 
    repository: Weave repository format 6
 
159
       control: Meta directory format 1
 
160
  working tree: Working tree format 3
 
161
        branch: Branch format 5
 
162
    repository: Knit repository format 1
162
163
 
163
164
In the working tree:
164
165
         1 unchanged
187
188
        branch1.bzrdir.sprout('bound')
188
189
        knit1_format = bzrdir.format_registry.make_bzrdir('knit')
189
190
        upgrade.upgrade('bound', knit1_format)
190
 
        branch3 = bzrdir.BzrDir.open('bound').open_branch()
 
191
        branch3 = controldir.ControlDir.open('bound').open_branch()
191
192
        branch3.bind(branch1)
192
193
        bound_tree = branch3.bzrdir.open_workingtree()
193
194
        out, err = self.run_bzr('info -v bound')
213
214
         0 removed
214
215
         0 renamed
215
216
         0 unknown
216
 
         1 ignored
 
217
         0 ignored
217
218
         0 versioned subdirectories
218
219
 
219
220
Branch history:
232
233
        self.assertEqual('', err)
233
234
 
234
235
        # Checkout standalone (same as above, but does not have parent set)
235
 
        branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
 
236
        branch4 = controldir.ControlDir.create_branch_convenience('checkout',
236
237
            format=knit1_format)
237
238
        branch4.bind(branch1)
238
239
        branch4.bzrdir.open_workingtree().update()
276
277
        tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
277
278
        branch5 = tree5.branch
278
279
        out, err = self.run_bzr('info -v lightcheckout')
 
280
        if "metaweave" in bzrdir.format_registry:
 
281
            format_description = "knit or metaweave"
 
282
        else:
 
283
            format_description = "knit"
279
284
        self.assertEqualDiff(
280
285
"""Lightweight checkout (format: %s)
281
286
Location:
284
289
 
285
290
Format:
286
291
       control: Meta directory format 1
287
 
  working tree: Working tree format 6
288
 
        branch: Branch format 4
289
 
    repository: Weave repository format 6
 
292
  working tree: Working tree format 3
 
293
        branch: Branch format 5
 
294
    repository: Knit repository format 1
290
295
 
291
296
In the working tree:
292
297
         1 unchanged
306
311
 
307
312
Repository:
308
313
         1 revision
309
 
""" % (self._repo_strings, datestring_first, datestring_first,), out)
 
314
""" % (format_description, datestring_first, datestring_first,), out)
310
315
        self.assertEqual('', err)
311
316
 
312
317
        # Update initial standalone branch
313
318
        self.build_tree(['standalone/b'])
314
319
        tree1.add('b')
315
320
        tree1.commit('commit two')
316
 
        rev = branch1.repository.get_revision(branch1.revision_history()[-1])
 
321
        rev = branch1.repository.get_revision(branch1.last_revision())
317
322
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
318
323
 
319
324
        # Out of date branched standalone branch will not be detected
320
325
        out, err = self.run_bzr('info -v branch')
321
326
        self.assertEqualDiff(
322
 
"""Standalone tree (format: weave)
 
327
"""Standalone tree (format: knit)
323
328
Location:
324
329
  branch root: branch
325
330
 
328
333
  parent branch: standalone
329
334
 
330
335
Format:
331
 
       control: All-in-one format 6
332
 
  working tree: Working tree format 2
333
 
        branch: Branch format 4
334
 
    repository: Weave repository format 6
 
336
       control: Meta directory format 1
 
337
  working tree: Working tree format 3
 
338
        branch: Branch format 5
 
339
    repository: Knit repository format 1
335
340
 
336
341
In the working tree:
337
342
         1 unchanged
381
386
         0 removed
382
387
         0 renamed
383
388
         0 unknown
384
 
         1 ignored
 
389
         0 ignored
385
390
         0 versioned subdirectories
386
391
 
387
392
Branch history:
446
451
 
447
452
Format:
448
453
       control: Meta directory format 1
449
 
  working tree: Working tree format 6
450
 
        branch: Branch format 4
451
 
    repository: Weave repository format 6
 
454
  working tree: Working tree format 3
 
455
        branch: Branch format 5
 
456
    repository: Knit repository format 1
452
457
 
453
458
Working tree is out of date: missing 1 revision.
454
459
 
470
475
 
471
476
Repository:
472
477
         2 revisions
473
 
""" % (self._repo_strings, datestring_first, datestring_last,), out)
 
478
""" % (format_description, datestring_first, datestring_last,), out)
474
479
        self.assertEqual('', err)
475
480
 
476
481
    def test_info_standalone_no_tree(self):
525
530
 
526
531
        # Create branch inside shared repository
527
532
        repo.bzrdir.root_transport.mkdir('branch')
528
 
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
529
 
            format=format)
 
533
        branch1 = controldir.ControlDir.create_branch_convenience(
 
534
            'repo/branch', format=format)
530
535
        out, err = self.run_bzr('info -v repo/branch')
531
536
        self.assertEqualDiff(
532
537
"""Repository branch (format: dirstate or knit)
567
572
        self.build_tree(['tree/lightcheckout/a'])
568
573
        tree2.add('a')
569
574
        tree2.commit('commit one')
570
 
        rev = repo.get_revision(branch2.revision_history()[0])
 
575
        rev = repo.get_revision(branch2.last_revision())
571
576
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
572
577
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
573
578
        self.assertEqualDiff(
686
691
        tree3.commit('commit two')
687
692
 
688
693
        # Out of date lightweight checkout
689
 
        rev = repo.get_revision(branch1.revision_history()[-1])
 
694
        rev = repo.get_revision(branch1.last_revision())
690
695
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
691
696
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
692
697
        self.assertEqualDiff(
799
804
 
800
805
        # Create two branches
801
806
        repo.bzrdir.root_transport.mkdir('branch1')
802
 
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
 
807
        branch1 = controldir.ControlDir.create_branch_convenience('repo/branch1',
803
808
            format=format)
804
809
        branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
805
810
 
842
847
        tree1 = branch1.bzrdir.open_workingtree()
843
848
        tree1.add('a')
844
849
        tree1.commit('commit one')
845
 
        rev = repo.get_revision(branch1.revision_history()[0])
 
850
        rev = repo.get_revision(branch1.last_revision())
846
851
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
847
852
        out, err = self.run_bzr('info -v repo/branch1')
848
853
        self.assertEqualDiff(
1217
1222
                                    format=bzrdir.BzrDirMetaFormat1())
1218
1223
        repo.set_make_working_trees(False)
1219
1224
        repo.bzrdir.root_transport.mkdir('branch')
1220
 
        repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1221
 
                                    format=bzrdir.BzrDirMetaFormat1())
 
1225
        repo_branch = controldir.ControlDir.create_branch_convenience(
 
1226
            'repo/branch', format=bzrdir.BzrDirMetaFormat1())
1222
1227
        # Do a heavy checkout
1223
1228
        transport.mkdir('tree')
1224
1229
        transport.mkdir('tree/checkout')
1225
 
        co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1226
 
            format=bzrdir.BzrDirMetaFormat1())
 
1230
        co_branch = controldir.ControlDir.create_branch_convenience(
 
1231
            'tree/checkout', format=bzrdir.BzrDirMetaFormat1())
1227
1232
        co_branch.bind(repo_branch)
1228
1233
        # Do a light checkout of the heavy one
1229
1234
        transport.mkdir('tree/lightcheckout')
1323
1328
            self.knownFailure('Win32 cannot run "bzr info"'
1324
1329
                              ' when the tree is locked.')
1325
1330
 
1326
 
    def test_info_locking_oslocks(self):
1327
 
        if sys.platform == "win32":
1328
 
            self.skip("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
 
 
1409
1331
    def test_info_stacked(self):
1410
1332
        # We have a mainline
1411
1333
        trunk_tree = self.make_branch_and_tree('mainline',
1424
1346
     stacked on: mainline
1425
1347
""", out)
1426
1348
        self.assertEqual("", err)
 
1349
 
 
1350
    def test_info_revinfo_optional(self):
 
1351
        tree = self.make_branch_and_tree('.')
 
1352
        def last_revision_info(self):
 
1353
            raise errors.UnsupportedOperation(last_revision_info, self)
 
1354
        self.overrideAttr(
 
1355
            branch.Branch, "last_revision_info", last_revision_info)
 
1356
        out, err = self.run_bzr('info -v .')
 
1357
        self.assertEqual(
 
1358
"""Standalone tree (format: 2a)
 
1359
Location:
 
1360
  branch root: .
 
1361
 
 
1362
Format:
 
1363
       control: Meta directory format 1
 
1364
  working tree: Working tree format 6
 
1365
        branch: Branch format 7
 
1366
    repository: Repository format 2a - rich roots, group compression and chk inventories
 
1367
 
 
1368
In the working tree:
 
1369
         0 unchanged
 
1370
         0 modified
 
1371
         0 added
 
1372
         0 removed
 
1373
         0 renamed
 
1374
         0 unknown
 
1375
         0 ignored
 
1376
         0 versioned subdirectories
 
1377
""", out)
 
1378
        self.assertEqual("", err)