/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: Aaron Bentley
  • Date: 2007-07-11 22:16:29 UTC
  • mto: This revision was merged to the branch mainline in revision 2606.
  • Revision ID: aaron.bentley@utoronto.ca-20070711221629-tbqh4m4mps264lxe
Fix trailing whitespace

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006, 2007 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
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
 
18
18
"""Tests for the info command of bzr."""
19
19
 
20
20
import sys
21
21
 
 
22
import bzrlib
22
23
from bzrlib import (
23
 
    branch,
24
24
    bzrdir,
25
 
    errors,
26
 
    info,
27
 
    osutils,
28
 
    tests,
29
 
    upgrade,
30
 
    urlutils,
 
25
    repository,
31
26
    )
32
 
from bzrlib.transport import memory
33
 
 
34
 
 
35
 
class TestInfo(tests.TestCaseWithTransport):
36
 
 
37
 
    def setUp(self):
38
 
        super(TestInfo, self).setUp()
39
 
        self._repo_strings = "2a"
 
27
from bzrlib.osutils import format_date
 
28
from bzrlib.tests import TestSkipped
 
29
from bzrlib.tests.blackbox import ExternalBase
 
30
 
 
31
 
 
32
class TestInfo(ExternalBase):
40
33
 
41
34
    def test_info_non_existing(self):
42
 
        self.vfs_transport_factory = memory.MemoryServer
43
 
        location = self.get_url()
 
35
        if sys.platform == "win32":
 
36
            location = "C:/i/do/not/exist/"
 
37
        else:
 
38
            location = "/i/do/not/exist/"
44
39
        out, err = self.run_bzr('info '+location, retcode=3)
45
40
        self.assertEqual(out, '')
46
 
        self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
 
41
        self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
47
42
 
48
43
    def test_info_standalone(self):
49
44
        transport = self.get_transport()
58
53
        self.assertEqualDiff(
59
54
"""Standalone tree (format: weave)
60
55
Location:
61
 
  branch root: standalone
62
 
""", out)
 
56
  branch root: %s
 
57
""" % branch1.bzrdir.root_transport.base, out)
63
58
        self.assertEqual('', err)
64
59
 
65
 
        # Standalone branch - verbose mode
66
60
        out, err = self.run_bzr('info standalone -v')
67
61
        self.assertEqualDiff(
68
62
"""Standalone tree (format: weave)
69
63
Location:
70
 
  branch root: standalone
71
 
 
72
 
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
77
 
 
78
 
In the working tree:
79
 
         0 unchanged
80
 
         0 modified
81
 
         1 added
82
 
         0 removed
83
 
         0 renamed
84
 
         0 unknown
85
 
         0 ignored
86
 
         0 versioned subdirectories
87
 
 
88
 
Branch history:
89
 
         0 revisions
90
 
 
91
 
Repository:
92
 
         0 revisions
93
 
""", out)
94
 
        self.assertEqual('', err)
95
 
 
96
 
        # Standalone branch - really verbose mode
97
 
        out, err = self.run_bzr('info standalone -vv')
98
 
        self.assertEqualDiff(
99
 
"""Standalone tree (format: weave)
100
 
Location:
101
 
  branch root: standalone
 
64
  branch root: %s
102
65
 
103
66
Format:
104
67
       control: All-in-one format 6
122
85
 
123
86
Repository:
124
87
         0 revisions
125
 
""", out)
 
88
         0 KiB
 
89
""" % branch1.bzrdir.root_transport.base, out)
126
90
        self.assertEqual('', err)
127
91
        tree1.commit('commit one')
128
92
        rev = branch1.repository.get_revision(branch1.revision_history()[0])
129
 
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
 
93
        datestring_first = format_date(rev.timestamp, rev.timezone)
130
94
 
131
95
        # Branch standalone with push location
132
96
        branch2 = branch1.bzrdir.sprout('branch').open_branch()
136
100
        self.assertEqualDiff(
137
101
"""Standalone tree (format: weave)
138
102
Location:
139
 
  branch root: branch
 
103
  branch root: %s
140
104
 
141
105
Related branches:
142
 
    push branch: standalone
143
 
  parent branch: standalone
144
 
""", out)
 
106
      parent branch: %s
 
107
  publish to branch: %s
 
108
""" % (branch2.bzrdir.root_transport.base,
 
109
       branch1.bzrdir.root_transport.base,
 
110
       branch1.bzrdir.root_transport.base), out)
145
111
        self.assertEqual('', err)
146
112
 
147
113
        out, err = self.run_bzr('info branch --verbose')
148
114
        self.assertEqualDiff(
149
115
"""Standalone tree (format: weave)
150
116
Location:
151
 
  branch root: branch
 
117
  branch root: %s
152
118
 
153
119
Related branches:
154
 
    push branch: standalone
155
 
  parent branch: standalone
 
120
      parent branch: %s
 
121
  publish to branch: %s
156
122
 
157
123
Format:
158
124
       control: All-in-one format 6
172
138
 
173
139
Branch history:
174
140
         1 revision
 
141
         1 committer
175
142
         0 days old
176
143
   first revision: %s
177
144
  latest revision: %s
178
145
 
179
146
Repository:
180
147
         1 revision
181
 
""" % (datestring_first, datestring_first,
 
148
         %d KiB
 
149
""" % (branch2.bzrdir.root_transport.base,
 
150
       branch1.bzrdir.root_transport.base,
 
151
       branch1.bzrdir.root_transport.base,
 
152
       datestring_first, datestring_first,
 
153
       # poking at _revision_store isn't all that clean, but neither is
 
154
       # having the ui test dependent on the exact overhead of a given store.
 
155
       branch2.repository._revision_store.total_size(
 
156
        branch2.repository.get_transaction())[1] / 1024,
182
157
       ), out)
183
158
        self.assertEqual('', err)
184
159
 
186
161
        # (creates backup as unknown)
187
162
        branch1.bzrdir.sprout('bound')
188
163
        knit1_format = bzrdir.format_registry.make_bzrdir('knit')
189
 
        upgrade.upgrade('bound', knit1_format)
190
 
        branch3 = bzrdir.BzrDir.open('bound').open_branch()
 
164
        bzrlib.upgrade.upgrade('bound', knit1_format)
 
165
        branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
191
166
        branch3.bind(branch1)
192
167
        bound_tree = branch3.bzrdir.open_workingtree()
193
168
        out, err = self.run_bzr('info -v bound')
194
169
        self.assertEqualDiff(
195
170
"""Checkout (format: knit)
196
171
Location:
197
 
       checkout root: bound
198
 
  checkout of branch: standalone
 
172
       checkout root: %s
 
173
  checkout of branch: %s
199
174
 
200
175
Related branches:
201
 
  parent branch: standalone
 
176
  parent branch: %s
202
177
 
203
178
Format:
204
179
       control: Meta directory format 1
212
187
         0 added
213
188
         0 removed
214
189
         0 renamed
215
 
         0 unknown
216
 
         1 ignored
 
190
         1 unknown
 
191
         0 ignored
217
192
         0 versioned subdirectories
218
193
 
219
194
Branch history:
220
195
         1 revision
 
196
         1 committer
221
197
         0 days old
222
198
   first revision: %s
223
199
  latest revision: %s
224
200
 
225
201
Repository:
226
202
         1 revision
227
 
""" % (bound_tree._format.get_format_description(),
 
203
         %d KiB
 
204
""" % (branch3.bzrdir.root_transport.base,
 
205
       branch1.bzrdir.root_transport.base,
 
206
       branch1.bzrdir.root_transport.base,
 
207
       bound_tree._format.get_format_description(),      
228
208
       branch3._format.get_format_description(),
229
209
       branch3.repository._format.get_format_description(),
230
210
       datestring_first, datestring_first,
 
211
       # poking at _revision_store isn't all that clean, but neither is
 
212
       # having the ui test dependent on the exact overhead of a given store.
 
213
       branch3.repository._revision_store.total_size(
 
214
        branch3.repository.get_transaction())[1] / 1024,
231
215
       ), out)
232
216
        self.assertEqual('', err)
233
217
 
234
218
        # Checkout standalone (same as above, but does not have parent set)
235
 
        branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
 
219
        branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
236
220
            format=knit1_format)
237
221
        branch4.bind(branch1)
238
222
        branch4.bzrdir.open_workingtree().update()
240
224
        self.assertEqualDiff(
241
225
"""Checkout (format: knit)
242
226
Location:
243
 
       checkout root: checkout
244
 
  checkout of branch: standalone
 
227
       checkout root: %s
 
228
  checkout of branch: %s
245
229
 
246
230
Format:
247
231
       control: Meta directory format 1
261
245
 
262
246
Branch history:
263
247
         1 revision
 
248
         1 committer
264
249
         0 days old
265
250
   first revision: %s
266
251
  latest revision: %s
267
252
 
268
253
Repository:
269
254
         1 revision
270
 
""" % (branch4.repository._format.get_format_description(),
 
255
         %d KiB
 
256
""" % (branch4.bzrdir.root_transport.base,
 
257
       branch1.bzrdir.root_transport.base,
 
258
       branch4.repository._format.get_format_description(),
271
259
       datestring_first, datestring_first,
 
260
       # poking at _revision_store isn't all that clean, but neither is
 
261
       # having the ui test dependent on the exact overhead of a given store.
 
262
       branch4.repository._revision_store.total_size(
 
263
        branch4.repository.get_transaction())[1] / 1024,
272
264
       ), out)
273
265
        self.assertEqual('', err)
274
266
 
277
269
        branch5 = tree5.branch
278
270
        out, err = self.run_bzr('info -v lightcheckout')
279
271
        self.assertEqualDiff(
280
 
"""Lightweight checkout (format: %s)
 
272
"""Lightweight checkout (format: dirstate or dirstate-tags)
281
273
Location:
282
 
  light checkout root: lightcheckout
283
 
   checkout of branch: standalone
 
274
  light checkout root: %s
 
275
   checkout of branch: %s
284
276
 
285
277
Format:
286
278
       control: Meta directory format 1
287
 
  working tree: Working tree format 6
 
279
  working tree: Working tree format 4
288
280
        branch: Branch format 4
289
281
    repository: Weave repository format 6
290
282
 
300
292
 
301
293
Branch history:
302
294
         1 revision
 
295
         1 committer
303
296
         0 days old
304
297
   first revision: %s
305
298
  latest revision: %s
306
299
 
307
300
Repository:
308
301
         1 revision
309
 
""" % (self._repo_strings, datestring_first, datestring_first,), out)
 
302
         0 KiB
 
303
""" % (tree5.bzrdir.root_transport.base,
 
304
       branch1.bzrdir.root_transport.base,
 
305
       datestring_first, datestring_first,
 
306
       ), out)
310
307
        self.assertEqual('', err)
311
308
 
312
309
        # Update initial standalone branch
314
311
        tree1.add('b')
315
312
        tree1.commit('commit two')
316
313
        rev = branch1.repository.get_revision(branch1.revision_history()[-1])
317
 
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
 
314
        datestring_last = format_date(rev.timestamp, rev.timezone)
318
315
 
319
316
        # Out of date branched standalone branch will not be detected
320
317
        out, err = self.run_bzr('info -v branch')
321
318
        self.assertEqualDiff(
322
319
"""Standalone tree (format: weave)
323
320
Location:
324
 
  branch root: branch
 
321
  branch root: %s
325
322
 
326
323
Related branches:
327
 
    push branch: standalone
328
 
  parent branch: standalone
 
324
      parent branch: %s
 
325
  publish to branch: %s
329
326
 
330
327
Format:
331
328
       control: All-in-one format 6
345
342
 
346
343
Branch history:
347
344
         1 revision
 
345
         1 committer
348
346
         0 days old
349
347
   first revision: %s
350
348
  latest revision: %s
351
349
 
352
350
Repository:
353
351
         1 revision
354
 
""" % (datestring_first, datestring_first,
 
352
         0 KiB
 
353
""" % (branch2.bzrdir.root_transport.base,
 
354
       branch1.bzrdir.root_transport.base,
 
355
       branch1.bzrdir.root_transport.base,
 
356
       datestring_first, datestring_first,
355
357
       ), out)
356
358
        self.assertEqual('', err)
357
359
 
360
362
        self.assertEqualDiff(
361
363
"""Checkout (format: knit)
362
364
Location:
363
 
       checkout root: bound
364
 
  checkout of branch: standalone
 
365
       checkout root: %s
 
366
  checkout of branch: %s
365
367
 
366
368
Related branches:
367
 
  parent branch: standalone
 
369
  parent branch: %s
368
370
 
369
371
Format:
370
372
       control: Meta directory format 1
380
382
         0 added
381
383
         0 removed
382
384
         0 renamed
383
 
         0 unknown
384
 
         1 ignored
 
385
         1 unknown
 
386
         0 ignored
385
387
         0 versioned subdirectories
386
388
 
387
389
Branch history:
388
390
         1 revision
 
391
         1 committer
389
392
         0 days old
390
393
   first revision: %s
391
394
  latest revision: %s
392
395
 
393
396
Repository:
394
397
         1 revision
395
 
""" % (branch3.repository._format.get_format_description(),
 
398
         %d KiB
 
399
""" % (branch3.bzrdir.root_transport.base,
 
400
       branch1.bzrdir.root_transport.base,
 
401
       branch1.bzrdir.root_transport.base,
 
402
       branch3.repository._format.get_format_description(),
396
403
       datestring_first, datestring_first,
 
404
       # poking at _revision_store isn't all that clean, but neither is
 
405
       # having the ui test dependent on the exact overhead of a given store.
 
406
       branch3.repository._revision_store.total_size(
 
407
        branch3.repository.get_transaction())[1] / 1024,
397
408
       ), out)
398
409
        self.assertEqual('', err)
399
410
 
402
413
        self.assertEqualDiff(
403
414
"""Checkout (format: knit)
404
415
Location:
405
 
       checkout root: checkout
406
 
  checkout of branch: standalone
 
416
       checkout root: %s
 
417
  checkout of branch: %s
407
418
 
408
419
Format:
409
420
       control: Meta directory format 1
425
436
 
426
437
Branch history:
427
438
         1 revision
 
439
         1 committer
428
440
         0 days old
429
441
   first revision: %s
430
442
  latest revision: %s
431
443
 
432
444
Repository:
433
445
         1 revision
434
 
""" % (branch4.repository._format.get_format_description(),
 
446
         %d KiB
 
447
""" % (branch4.bzrdir.root_transport.base,
 
448
       branch1.bzrdir.root_transport.base,
 
449
       branch4.repository._format.get_format_description(),
435
450
       datestring_first, datestring_first,
 
451
       # poking at _revision_store isn't all that clean, but neither is
 
452
       # having the ui test dependent on the exact overhead of a given store.
 
453
       branch4.repository._revision_store.total_size(
 
454
        branch4.repository.get_transaction())[1] / 1024,
436
455
       ), out)
437
456
        self.assertEqual('', err)
438
457
 
439
458
        # Out of date lightweight checkout
440
459
        out, err = self.run_bzr('info lightcheckout --verbose')
441
460
        self.assertEqualDiff(
442
 
"""Lightweight checkout (format: %s)
 
461
"""Lightweight checkout (format: dirstate or dirstate-tags)
443
462
Location:
444
 
  light checkout root: lightcheckout
445
 
   checkout of branch: standalone
 
463
  light checkout root: %s
 
464
   checkout of branch: %s
446
465
 
447
466
Format:
448
467
       control: Meta directory format 1
449
 
  working tree: Working tree format 6
 
468
  working tree: Working tree format 4
450
469
        branch: Branch format 4
451
470
    repository: Weave repository format 6
452
471
 
464
483
 
465
484
Branch history:
466
485
         2 revisions
 
486
         1 committer
467
487
         0 days old
468
488
   first revision: %s
469
489
  latest revision: %s
470
490
 
471
491
Repository:
472
492
         2 revisions
473
 
""" % (self._repo_strings, datestring_first, datestring_last,), out)
 
493
         0 KiB
 
494
""" % (tree5.bzrdir.root_transport.base,
 
495
       branch1.bzrdir.root_transport.base,
 
496
       datestring_first, datestring_last,
 
497
       ), out)
474
498
        self.assertEqual('', err)
475
499
 
476
500
    def test_info_standalone_no_tree(self):
480
504
        repo = branch.repository
481
505
        out, err = self.run_bzr('info branch -v')
482
506
        self.assertEqualDiff(
483
 
"""Standalone branch (format: %s)
 
507
"""Standalone branch (format: dirstate or knit)
484
508
Location:
485
 
  branch root: branch
 
509
  branch root: %s
486
510
 
487
511
Format:
488
512
       control: Meta directory format 1
491
515
 
492
516
Branch history:
493
517
         0 revisions
 
518
         0 committers
494
519
 
495
520
Repository:
496
521
         0 revisions
497
 
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
 
522
         0 KiB
 
523
""" % (branch.bzrdir.root_transport.base,
498
524
       format.get_branch_format().get_format_description(),
499
525
       format.repository_format.get_format_description(),
500
526
       ), out)
519
545
 
520
546
Repository:
521
547
         0 revisions
522
 
""" % ('repo', format.repository_format.get_format_description(),
 
548
         0 KiB
 
549
""" % (repo.bzrdir.root_transport.base,
 
550
       format.repository_format.get_format_description(),
523
551
       ), out)
524
552
        self.assertEqual('', err)
525
553
 
531
559
        self.assertEqualDiff(
532
560
"""Repository branch (format: dirstate or knit)
533
561
Location:
534
 
  shared repository: repo
535
 
  repository branch: repo/branch
 
562
  shared repository: %s
 
563
  repository branch: branch
536
564
 
537
565
Format:
538
566
       control: Meta directory format 1
541
569
 
542
570
Branch history:
543
571
         0 revisions
 
572
         0 committers
544
573
 
545
574
Repository:
546
575
         0 revisions
547
 
""" % (format.get_branch_format().get_format_description(),
 
576
         0 KiB
 
577
""" % (repo.bzrdir.root_transport.base,
 
578
       format.get_branch_format().get_format_description(),
548
579
       format.repository_format.get_format_description(),
549
580
       ), out)
550
581
        self.assertEqual('', err)
552
583
        # Create lightweight checkout
553
584
        transport.mkdir('tree')
554
585
        transport.mkdir('tree/lightcheckout')
555
 
        tree2 = branch1.create_checkout('tree/lightcheckout',
 
586
        tree2 = branch1.create_checkout('tree/lightcheckout', 
556
587
            lightweight=True)
557
588
        branch2 = tree2.branch
558
589
        self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
568
599
        tree2.add('a')
569
600
        tree2.commit('commit one')
570
601
        rev = repo.get_revision(branch2.revision_history()[0])
571
 
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
 
602
        datestring_first = format_date(rev.timestamp, rev.timezone)
572
603
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
573
604
        self.assertEqualDiff(
574
 
"""Lightweight checkout (format: %s)
 
605
"""Lightweight checkout (format: dirstate or dirstate-tags)
575
606
Location:
576
 
  light checkout root: tree/lightcheckout
577
 
   checkout of branch: repo/branch
578
 
    shared repository: repo
 
607
  light checkout root: %s
 
608
   checkout of branch: %s
 
609
    shared repository: %s
579
610
 
580
611
Format:
581
612
       control: Meta directory format 1
582
 
  working tree: Working tree format 6
 
613
  working tree: Working tree format 4
583
614
        branch: %s
584
615
    repository: %s
585
616
 
595
626
 
596
627
Branch history:
597
628
         1 revision
 
629
         1 committer
598
630
         0 days old
599
631
   first revision: %s
600
632
  latest revision: %s
601
633
 
602
634
Repository:
603
635
         1 revision
604
 
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
 
636
         %d KiB
 
637
""" % (tree2.bzrdir.root_transport.base,
 
638
       tree2.branch.bzrdir.root_transport.base,
 
639
       repo.bzrdir.root_transport.base,
 
640
       format.get_branch_format().get_format_description(),
605
641
       format.repository_format.get_format_description(),
606
642
       datestring_first, datestring_first,
 
643
       # poking at _revision_store isn't all that clean, but neither is
 
644
       # having the ui test dependent on the exact overhead of a given store.
 
645
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
607
646
       ), out)
608
647
        self.assertEqual('', err)
609
648
 
610
649
        # Out of date checkout
611
650
        out, err = self.run_bzr('info -v tree/checkout')
612
651
        self.assertEqualDiff(
613
 
"""Checkout (format: unnamed)
 
652
"""Checkout (format: dirstate)
614
653
Location:
615
 
       checkout root: tree/checkout
616
 
  checkout of branch: repo/branch
 
654
       checkout root: %s
 
655
  checkout of branch: %s
617
656
 
618
657
Format:
619
658
       control: Meta directory format 1
620
 
  working tree: Working tree format 6
 
659
  working tree: Working tree format 4
621
660
        branch: %s
622
661
    repository: %s
623
662
 
635
674
 
636
675
Branch history:
637
676
         0 revisions
 
677
         0 committers
638
678
 
639
679
Repository:
640
680
         0 revisions
641
 
""" % (format.get_branch_format().get_format_description(),
 
681
         0 KiB
 
682
""" % (tree3.bzrdir.root_transport.base,
 
683
       branch1.bzrdir.root_transport.base,
 
684
       format.get_branch_format().get_format_description(),
642
685
       format.repository_format.get_format_description(),
643
686
       ), out)
644
687
        self.assertEqual('', err)
649
692
        tree3.add('b')
650
693
        out, err = self.run_bzr('info tree/checkout --verbose')
651
694
        self.assertEqualDiff(
652
 
"""Checkout (format: unnamed)
 
695
"""Checkout (format: dirstate)
653
696
Location:
654
 
       checkout root: tree/checkout
655
 
  checkout of branch: repo/branch
 
697
       checkout root: %s
 
698
  checkout of branch: %s
656
699
 
657
700
Format:
658
701
       control: Meta directory format 1
659
 
  working tree: Working tree format 6
 
702
  working tree: Working tree format 4
660
703
        branch: %s
661
704
    repository: %s
662
705
 
672
715
 
673
716
Branch history:
674
717
         1 revision
 
718
         1 committer
675
719
         0 days old
676
720
   first revision: %s
677
721
  latest revision: %s
678
722
 
679
723
Repository:
680
724
         1 revision
681
 
""" % (format.get_branch_format().get_format_description(),
 
725
         %d KiB
 
726
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
 
727
       format.get_branch_format().get_format_description(),
682
728
       format.repository_format.get_format_description(),
683
729
       datestring_first, datestring_first,
 
730
       # poking at _revision_store isn't all that clean, but neither is
 
731
       # having the ui test dependent on the exact overhead of a given store.
 
732
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
684
733
       ), out)
685
734
        self.assertEqual('', err)
686
735
        tree3.commit('commit two')
687
736
 
688
737
        # Out of date lightweight checkout
689
738
        rev = repo.get_revision(branch1.revision_history()[-1])
690
 
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
 
739
        datestring_last = format_date(rev.timestamp, rev.timezone)
691
740
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
692
741
        self.assertEqualDiff(
693
 
"""Lightweight checkout (format: %s)
 
742
"""Lightweight checkout (format: dirstate or dirstate-tags)
694
743
Location:
695
 
  light checkout root: tree/lightcheckout
696
 
   checkout of branch: repo/branch
697
 
    shared repository: repo
 
744
  light checkout root: %s
 
745
   checkout of branch: %s
 
746
    shared repository: %s
698
747
 
699
748
Format:
700
749
       control: Meta directory format 1
701
 
  working tree: Working tree format 6
 
750
  working tree: Working tree format 4
702
751
        branch: %s
703
752
    repository: %s
704
753
 
716
765
 
717
766
Branch history:
718
767
         2 revisions
 
768
         1 committer
719
769
         0 days old
720
770
   first revision: %s
721
771
  latest revision: %s
722
772
 
723
773
Repository:
724
774
         2 revisions
725
 
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
 
775
         %d KiB
 
776
""" % (tree2.bzrdir.root_transport.base,
 
777
       tree2.branch.bzrdir.root_transport.base,
 
778
       repo.bzrdir.root_transport.base,
 
779
       format.get_branch_format().get_format_description(),
726
780
       format.repository_format.get_format_description(),
727
781
       datestring_first, datestring_last,
 
782
       # poking at _revision_store isn't all that clean, but neither is
 
783
       # having the ui test dependent on the exact overhead of a given store.
 
784
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
728
785
       ), out)
729
786
        self.assertEqual('', err)
730
787
 
733
790
        self.assertEqualDiff(
734
791
"""Repository branch (format: dirstate or knit)
735
792
Location:
736
 
  shared repository: repo
737
 
  repository branch: repo/branch
 
793
  shared repository: %s
 
794
  repository branch: branch
738
795
 
739
796
Format:
740
797
       control: Meta directory format 1
743
800
 
744
801
Branch history:
745
802
         2 revisions
 
803
         1 committer
746
804
         0 days old
747
805
   first revision: %s
748
806
  latest revision: %s
749
807
 
750
808
Repository:
751
809
         2 revisions
752
 
""" % (format.get_branch_format().get_format_description(),
 
810
         %d KiB
 
811
""" % (repo.bzrdir.root_transport.base,
 
812
       format.get_branch_format().get_format_description(),
753
813
       format.repository_format.get_format_description(),
754
814
       datestring_first, datestring_last,
 
815
       # poking at _revision_store isn't all that clean, but neither is
 
816
       # having the ui test dependent on the exact overhead of a given store.
 
817
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
755
818
       ), out)
756
819
        self.assertEqual('', err)
757
820
 
760
823
        self.assertEqualDiff(
761
824
"""Shared repository (format: dirstate or dirstate-tags or knit)
762
825
Location:
763
 
  shared repository: repo
 
826
  shared repository: %s
764
827
 
765
828
Format:
766
829
       control: Meta directory format 1
768
831
 
769
832
Repository:
770
833
         2 revisions
771
 
""" % (format.repository_format.get_format_description(),
 
834
         %d KiB
 
835
""" % (repo.bzrdir.root_transport.base,
 
836
       format.repository_format.get_format_description(),
 
837
       # poking at _revision_store isn't all that clean, but neither is
 
838
       # having the ui test dependent on the exact overhead of a given store.
 
839
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
772
840
       ), out)
773
841
        self.assertEqual('', err)
774
842
 
783
851
        self.assertEqualDiff(
784
852
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
785
853
Location:
786
 
  shared repository: repo
 
854
  shared repository: %s
787
855
 
788
856
Format:
789
857
       control: Meta directory format 1
793
861
 
794
862
Repository:
795
863
         0 revisions
796
 
""" % (format.repository_format.get_format_description(),
 
864
         0 KiB
 
865
""" % (repo.bzrdir.root_transport.base,
 
866
       format.repository_format.get_format_description(),
797
867
       ), out)
798
868
        self.assertEqual('', err)
799
869
 
808
878
        self.assertEqualDiff(
809
879
"""Repository tree (format: knit)
810
880
Location:
811
 
  shared repository: repo
812
 
  repository branch: repo/branch1
 
881
  shared repository: %s
 
882
  repository branch: branch1
813
883
 
814
884
Format:
815
885
       control: Meta directory format 1
829
899
 
830
900
Branch history:
831
901
         0 revisions
 
902
         0 committers
832
903
 
833
904
Repository:
834
905
         0 revisions
835
 
""" % (format.get_branch_format().get_format_description(),
 
906
         0 KiB
 
907
""" % (repo.bzrdir.root_transport.base,
 
908
       format.get_branch_format().get_format_description(),
836
909
       format.repository_format.get_format_description(),
837
910
       ), out)
838
911
        self.assertEqual('', err)
843
916
        tree1.add('a')
844
917
        tree1.commit('commit one')
845
918
        rev = repo.get_revision(branch1.revision_history()[0])
846
 
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
 
919
        datestring_first = format_date(rev.timestamp, rev.timezone)
847
920
        out, err = self.run_bzr('info -v repo/branch1')
848
921
        self.assertEqualDiff(
849
922
"""Repository tree (format: knit)
850
923
Location:
851
 
  shared repository: repo
852
 
  repository branch: repo/branch1
 
924
  shared repository: %s
 
925
  repository branch: branch1
853
926
 
854
927
Format:
855
928
       control: Meta directory format 1
869
942
 
870
943
Branch history:
871
944
         1 revision
 
945
         1 committer
872
946
         0 days old
873
947
   first revision: %s
874
948
  latest revision: %s
875
949
 
876
950
Repository:
877
951
         1 revision
878
 
""" % (format.get_branch_format().get_format_description(),
 
952
         %d KiB
 
953
""" % (repo.bzrdir.root_transport.base,
 
954
       format.get_branch_format().get_format_description(),
879
955
       format.repository_format.get_format_description(),
880
956
       datestring_first, datestring_first,
 
957
       # poking at _revision_store isn't all that clean, but neither is
 
958
       # having the ui test dependent on the exact overhead of a given store.
 
959
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
881
960
       ), out)
882
961
        self.assertEqual('', err)
883
962
 
886
965
        self.assertEqualDiff(
887
966
"""Repository tree (format: knit)
888
967
Location:
889
 
  shared repository: repo
890
 
  repository branch: repo/branch2
 
968
  shared repository: %s
 
969
  repository branch: branch2
891
970
 
892
971
Related branches:
893
 
  parent branch: repo/branch1
 
972
  parent branch: %s
894
973
 
895
974
Format:
896
975
       control: Meta directory format 1
910
989
 
911
990
Branch history:
912
991
         0 revisions
 
992
         0 committers
913
993
 
914
994
Repository:
915
995
         1 revision
916
 
""" % (format.get_branch_format().get_format_description(),
 
996
         %d KiB
 
997
""" % (repo.bzrdir.root_transport.base,
 
998
       branch1.bzrdir.root_transport.base,
 
999
       format.get_branch_format().get_format_description(),
917
1000
       format.repository_format.get_format_description(),
 
1001
       # poking at _revision_store isn't all that clean, but neither is
 
1002
       # having the ui test dependent on the exact overhead of a given store.
 
1003
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
918
1004
       ), out)
919
1005
        self.assertEqual('', err)
920
1006
 
925
1011
        self.assertEqualDiff(
926
1012
"""Repository tree (format: knit)
927
1013
Location:
928
 
  shared repository: repo
929
 
  repository branch: repo/branch2
 
1014
  shared repository: %s
 
1015
  repository branch: branch2
930
1016
 
931
1017
Related branches:
932
 
  parent branch: repo/branch1
 
1018
  parent branch: %s
933
1019
 
934
1020
Format:
935
1021
       control: Meta directory format 1
949
1035
 
950
1036
Branch history:
951
1037
         1 revision
 
1038
         1 committer
952
1039
         0 days old
953
1040
   first revision: %s
954
1041
  latest revision: %s
955
1042
 
956
1043
Repository:
957
1044
         1 revision
958
 
""" % (format.get_branch_format().get_format_description(),
 
1045
         %d KiB
 
1046
""" % (repo.bzrdir.root_transport.base,
 
1047
       branch1.bzrdir.root_transport.base,
 
1048
       format.get_branch_format().get_format_description(),
959
1049
       format.repository_format.get_format_description(),
960
1050
       datestring_first, datestring_first,
 
1051
       # poking at _revision_store isn't all that clean, but neither is
 
1052
       # having the ui test dependent on the exact overhead of a given store.
 
1053
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
961
1054
       ), out)
962
1055
        self.assertEqual('', err)
963
1056
 
966
1059
        self.assertEqualDiff(
967
1060
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
968
1061
Location:
969
 
  shared repository: repo
 
1062
  shared repository: %s
970
1063
 
971
1064
Format:
972
1065
       control: Meta directory format 1
976
1069
 
977
1070
Repository:
978
1071
         1 revision
979
 
""" % (format.repository_format.get_format_description(),
 
1072
         %d KiB
 
1073
""" % (repo.bzrdir.root_transport.base,
 
1074
       format.repository_format.get_format_description(),
 
1075
       # poking at _revision_store isn't all that clean, but neither is
 
1076
       # having the ui test dependent on the exact overhead of a given store.
 
1077
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
980
1078
       ),
981
1079
       out)
982
1080
        self.assertEqual('', err)
983
 
 
 
1081
    
984
1082
    def test_info_shared_repository_with_tree_in_root(self):
985
1083
        format = bzrdir.format_registry.make_bzrdir('knit')
986
1084
        transport = self.get_transport()
992
1090
        self.assertEqualDiff(
993
1091
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
994
1092
Location:
995
 
  shared repository: repo
 
1093
  shared repository: %s
996
1094
 
997
1095
Format:
998
1096
       control: Meta directory format 1
1002
1100
 
1003
1101
Repository:
1004
1102
         0 revisions
1005
 
""" % (format.repository_format.get_format_description(),
 
1103
         0 KiB
 
1104
""" % (repo.bzrdir.root_transport.base,
 
1105
       format.repository_format.get_format_description(),
1006
1106
       ), out)
1007
1107
        self.assertEqual('', err)
1008
1108
 
1014
1114
        self.assertEqualDiff(
1015
1115
"""Repository tree (format: knit)
1016
1116
Location:
1017
 
  shared repository: repo
1018
 
  repository branch: repo
 
1117
  shared repository: %s
 
1118
  repository branch: .
1019
1119
 
1020
1120
Format:
1021
1121
       control: Meta directory format 1
1035
1135
 
1036
1136
Branch history:
1037
1137
         0 revisions
 
1138
         0 committers
1038
1139
 
1039
1140
Repository:
1040
1141
         0 revisions
1041
 
""" % (format.get_branch_format().get_format_description(),
 
1142
         0 KiB
 
1143
""" % (repo.bzrdir.root_transport.base,
 
1144
       format.get_branch_format().get_format_description(),
1042
1145
       format.repository_format.get_format_description(),
1043
1146
       ), out)
1044
1147
        self.assertEqual('', err)
1045
1148
 
1046
 
    def test_info_repository_hook(self):
1047
 
        format = bzrdir.format_registry.make_bzrdir('knit')
1048
 
        def repo_info(repo, stats, outf):
1049
 
            outf.write("more info\n")
1050
 
        info.hooks.install_named_hook('repository', repo_info, None)
1051
 
        # Create shared repository with working trees
1052
 
        repo = self.make_repository('repo', shared=True, format=format)
1053
 
        out, err = self.run_bzr('info -v repo')
1054
 
        self.assertEqualDiff(
1055
 
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1056
 
Location:
1057
 
  shared repository: repo
1058
 
 
1059
 
Format:
1060
 
       control: Meta directory format 1
1061
 
    repository: %s
1062
 
 
1063
 
Create working tree for new branches inside the repository.
1064
 
 
1065
 
Repository:
1066
 
         0 revisions
1067
 
more info
1068
 
""" % (format.repository_format.get_format_description(),
1069
 
       ), out)
1070
 
        self.assertEqual('', err)
1071
 
 
1072
 
    def assertCheckoutStatusOutput(self,
 
1149
    def assertCheckoutStatusOutput(self, 
1073
1150
        command_string, lco_tree, shared_repo=None,
1074
1151
        repo_branch=None,
1075
1152
        tree_locked=False,
1084
1161
        allow us, the test writers, to document what *should* be present in
1085
1162
        the output. Removing this separation would remove the value of the
1086
1163
        tests.
1087
 
 
 
1164
        
1088
1165
        :param path: the path to the light checkout.
1089
1166
        :param lco_tree: the tree object for the light checkout.
1090
1167
        :param shared_repo: A shared repository is in use, expect that in
1094
1171
        :param tree_locked: If true, expect the tree to be locked.
1095
1172
        :param branch_locked: If true, expect the branch to be locked.
1096
1173
        :param repo_locked: If true, expect the repository to be locked.
1097
 
            Note that the lco_tree.branch.repository is inspected, and if is not
1098
 
            actually locked then this parameter is overridden. This is because
1099
 
            pack repositories do not have any public API for obtaining an
1100
 
            exclusive repository wide lock.
1101
 
        :param verbose: verbosity level: 2 or higher to show committers
 
1174
        :param verbose: If true, expect verbose output
1102
1175
        """
1103
 
        def friendly_location(url):
1104
 
            path = urlutils.unescape_for_display(url, 'ascii')
1105
 
            try:
1106
 
                return osutils.relpath(osutils.getcwd(), path)
1107
 
            except errors.PathNotChild:
1108
 
                return path
1109
 
 
1110
 
        if tree_locked:
1111
 
            # We expect this to fail because of locking errors.
1112
 
            # (A write-locked file cannot be read-locked
1113
 
            # in the different process -- either on win32 or on linux).
 
1176
        if tree_locked and sys.platform == 'win32':
 
1177
            # We expect this to fail because of locking errors. (A write-locked
 
1178
            # file cannot be read-locked in the same process).
1114
1179
            # This should be removed when the locking errors are fixed.
1115
 
            self.expectFailure('OS locks are exclusive '
1116
 
                'for different processes (Bug #174055)',
1117
 
                self.run_bzr_subprocess,
1118
 
                'info ' + command_string)
 
1180
            args = command_string.split(' ')
 
1181
            self.run_bzr_error([], 'info', *args)
 
1182
            return
1119
1183
        out, err = self.run_bzr('info %s' % command_string)
1120
1184
        description = {
1121
1185
            (True, True): 'Lightweight checkout',
1123
1187
            (False, True): 'Lightweight checkout',
1124
1188
            (False, False): 'Checkout',
1125
1189
            }[(shared_repo is not None, light_checkout)]
1126
 
        format = {True: self._repo_strings,
1127
 
                  False: 'unnamed'}[light_checkout]
1128
 
        if repo_locked:
1129
 
            repo_locked = lco_tree.branch.repository.get_physical_lock_status()
 
1190
        format = {True: 'dirstate or dirstate-tags',
 
1191
                  False: 'dirstate'}[light_checkout]
1130
1192
        if repo_locked or branch_locked or tree_locked:
1131
1193
            def locked_message(a_bool):
1132
1194
                if a_bool:
1148
1210
        extra_space = ''
1149
1211
        if light_checkout:
1150
1212
            tree_data = ("  light checkout root: %s\n" %
1151
 
                friendly_location(lco_tree.bzrdir.root_transport.base))
 
1213
                lco_tree.bzrdir.root_transport.base)
1152
1214
            extra_space = ' '
1153
1215
        if lco_tree.branch.get_bound_location() is not None:
1154
1216
            tree_data += ("%s       checkout root: %s\n" % (extra_space,
1155
 
                friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
 
1217
                lco_tree.branch.bzrdir.root_transport.base))
1156
1218
        if shared_repo is not None:
1157
1219
            branch_data = (
1158
1220
                "   checkout of branch: %s\n"
1159
1221
                "    shared repository: %s\n" %
1160
 
                (friendly_location(repo_branch.bzrdir.root_transport.base),
1161
 
                 friendly_location(shared_repo.bzrdir.root_transport.base)))
 
1222
                (repo_branch.bzrdir.root_transport.base,
 
1223
                 shared_repo.bzrdir.root_transport.base))
1162
1224
        elif repo_branch is not None:
1163
1225
            branch_data = (
1164
1226
                "%s  checkout of branch: %s\n" %
1165
1227
                (extra_space,
1166
 
                 friendly_location(repo_branch.bzrdir.root_transport.base)))
 
1228
                 repo_branch.bzrdir.root_transport.base))
1167
1229
        else:
1168
1230
            branch_data = ("   checkout of branch: %s\n" %
1169
1231
                lco_tree.branch.bzrdir.root_transport.base)
1170
 
 
1171
 
        if verbose >= 2:
 
1232
        
 
1233
        if verbose:
1172
1234
            verbose_info = '         0 committers\n'
1173
1235
        else:
1174
1236
            verbose_info = ''
1175
 
 
 
1237
            
1176
1238
        self.assertEqualDiff(
1177
1239
"""%s (format: %s)
1178
1240
Location:
1198
1260
%s
1199
1261
Repository:
1200
1262
         0 revisions
 
1263
         0 KiB
1201
1264
""" %  (description,
1202
1265
        format,
1203
1266
        tree_data,
1214
1277
        transport = self.get_transport()
1215
1278
        # Create shared repository with a branch
1216
1279
        repo = self.make_repository('repo', shared=True,
1217
 
                                    format=bzrdir.BzrDirMetaFormat1())
 
1280
                                    format=bzrlib.bzrdir.BzrDirMetaFormat1())
1218
1281
        repo.set_make_working_trees(False)
1219
1282
        repo.bzrdir.root_transport.mkdir('branch')
1220
1283
        repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1221
 
                                    format=bzrdir.BzrDirMetaFormat1())
 
1284
                                    format=bzrlib.bzrdir.BzrDirMetaFormat1())
1222
1285
        # Do a heavy checkout
1223
1286
        transport.mkdir('tree')
1224
1287
        transport.mkdir('tree/checkout')
1225
 
        co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1226
 
            format=bzrdir.BzrDirMetaFormat1())
 
1288
        co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
 
1289
            format=bzrlib.bzrdir.BzrDirMetaFormat1())
1227
1290
        co_branch.bind(repo_branch)
1228
1291
        # Do a light checkout of the heavy one
1229
1292
        transport.mkdir('tree/lightcheckout')
1230
 
        lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1231
 
        branch.BranchReferenceFormat().initialize(lco_dir,
1232
 
            target_branch=co_branch)
 
1293
        lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
 
1294
        bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1233
1295
        lco_dir.create_workingtree()
1234
1296
        lco_tree = lco_dir.open_workingtree()
1235
1297
 
1325
1387
 
1326
1388
    def test_info_locking_oslocks(self):
1327
1389
        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()
 
1390
            raise TestSkipped("don't use oslocks on win32 in unix manner")
1334
1391
 
1335
1392
        tree = self.make_branch_and_tree('branch',
1336
 
                                         format=bzrdir.BzrDirFormat6())
 
1393
                                         format=bzrlib.bzrdir.BzrDirFormat6())
1337
1394
 
1338
1395
        # Test all permutations of locking the working tree, branch and repository
1339
1396
        # XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1366
1423
 
1367
1424
Branch history:
1368
1425
         0 revisions
 
1426
         0 committers
1369
1427
 
1370
1428
Repository:
1371
1429
         0 revisions
1372
 
""" % ('branch', tree.branch.repository._format.get_format_description(),
 
1430
         0 KiB
 
1431
""" % (tree.bzrdir.root_transport.base,
 
1432
       tree.branch.repository._format.get_format_description(),
1373
1433
       ), out)
1374
1434
        self.assertEqual('', err)
1375
1435
        # L L L
1398
1458
 
1399
1459
Branch history:
1400
1460
         0 revisions
 
1461
         0 committers
1401
1462
 
1402
1463
Repository:
1403
1464
         0 revisions
1404
 
""" % ('branch', tree.branch.repository._format.get_format_description(),
 
1465
         0 KiB
 
1466
""" % (tree.bzrdir.root_transport.base,
 
1467
       tree.branch.repository._format.get_format_description(),
1405
1468
       ), out)
1406
1469
        self.assertEqual('', err)
1407
1470
        tree.unlock()
1408
 
 
1409
 
    def test_info_stacked(self):
1410
 
        # We have a mainline
1411
 
        trunk_tree = self.make_branch_and_tree('mainline',
1412
 
            format='1.6')
1413
 
        trunk_tree.commit('mainline')
1414
 
        # and a branch from it which is stacked
1415
 
        new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1416
 
        out, err = self.run_bzr('info newbranch')
1417
 
        self.assertEqual(
1418
 
"""Standalone tree (format: 1.6)
1419
 
Location:
1420
 
  branch root: newbranch
1421
 
 
1422
 
Related branches:
1423
 
  parent branch: mainline
1424
 
     stacked on: mainline
1425
 
""", out)
1426
 
        self.assertEqual("", err)