/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: Martin Pool
  • Date: 2007-02-06 08:16:13 UTC
  • mto: This revision was merged to the branch mainline in revision 2283.
  • Revision ID: mbp@sourcefrog.net-20070206081613-dxop566k13bll6j0
Move KnitFormat2 into repofmt

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2006, 2007 Canonical Ltd
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
 
 
18
"""Tests for the info command of bzr."""
 
19
 
 
20
import sys
 
21
 
 
22
import bzrlib
 
23
from bzrlib import (
 
24
    bzrdir,
 
25
    repository,
 
26
    )
 
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):
 
33
 
 
34
    def test_info_non_existing(self):
 
35
        if sys.platform == "win32":
 
36
            location = "C:/i/do/not/exist/"
 
37
        else:
 
38
            location = "/i/do/not/exist/"
 
39
        out, err = self.runbzr('info '+location, retcode=3)
 
40
        self.assertEqual(out, '')
 
41
        self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
 
42
 
 
43
    def test_info_standalone(self):
 
44
        transport = self.get_transport()
 
45
 
 
46
        # Create initial standalone branch
 
47
        tree1 = self.make_branch_and_tree('standalone', 'weave')
 
48
        self.build_tree(['standalone/a'])
 
49
        tree1.add('a')
 
50
        branch1 = tree1.branch
 
51
        out, err = self.runbzr('info standalone')
 
52
        self.assertEqualDiff(
 
53
"""Location:
 
54
  branch root: %s
 
55
 
 
56
Format:
 
57
       control: All-in-one format 6
 
58
  working tree: Working tree format 2
 
59
        branch: Branch format 4
 
60
    repository: Weave repository format 6
 
61
 
 
62
In the working tree:
 
63
         0 unchanged
 
64
         0 modified
 
65
         1 added
 
66
         0 removed
 
67
         0 renamed
 
68
         0 unknown
 
69
         0 ignored
 
70
         0 versioned subdirectories
 
71
 
 
72
Branch history:
 
73
         0 revisions
 
74
 
 
75
Revision store:
 
76
         0 revisions
 
77
         0 KiB
 
78
""" % branch1.bzrdir.root_transport.base, out)
 
79
        self.assertEqual('', err)
 
80
        tree1.commit('commit one')
 
81
        rev = branch1.repository.get_revision(branch1.revision_history()[0])
 
82
        datestring_first = format_date(rev.timestamp, rev.timezone)
 
83
 
 
84
        # Branch standalone with push location
 
85
        branch2 = branch1.bzrdir.sprout('branch').open_branch()
 
86
        branch2.set_push_location(branch1.bzrdir.root_transport.base)
 
87
        out, err = self.runbzr('info branch --verbose')
 
88
        self.assertEqualDiff(
 
89
"""Location:
 
90
  branch root: %s
 
91
 
 
92
Related branches:
 
93
      parent branch: %s
 
94
  publish to branch: %s
 
95
 
 
96
Format:
 
97
       control: All-in-one format 6
 
98
  working tree: Working tree format 2
 
99
        branch: Branch format 4
 
100
    repository: Weave repository format 6
 
101
 
 
102
In the working tree:
 
103
         1 unchanged
 
104
         0 modified
 
105
         0 added
 
106
         0 removed
 
107
         0 renamed
 
108
         0 unknown
 
109
         0 ignored
 
110
         0 versioned subdirectories
 
111
 
 
112
Branch history:
 
113
         1 revision
 
114
         1 committer
 
115
         0 days old
 
116
   first revision: %s
 
117
  latest revision: %s
 
118
 
 
119
Revision store:
 
120
         1 revision
 
121
         %d KiB
 
122
""" % (branch2.bzrdir.root_transport.base,
 
123
       branch1.bzrdir.root_transport.base,
 
124
       branch1.bzrdir.root_transport.base,
 
125
       datestring_first, datestring_first,
 
126
       # poking at _revision_store isn't all that clean, but neither is
 
127
       # having the ui test dependent on the exact overhead of a given store.
 
128
       branch2.repository._revision_store.total_size(
 
129
        branch2.repository.get_transaction())[1] / 1024,
 
130
       ), out)
 
131
        self.assertEqual('', err)
 
132
 
 
133
        # Branch and bind to standalone, needs upgrade to metadir
 
134
        # (creates backup as unknown)
 
135
        branch1.bzrdir.sprout('bound')
 
136
        knit1_format = bzrdir.format_registry.make_bzrdir('knit')
 
137
        bzrlib.upgrade.upgrade('bound', knit1_format)
 
138
        branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
 
139
        branch3.bind(branch1)
 
140
        bound_tree = branch3.bzrdir.open_workingtree()
 
141
        out, err = self.runbzr('info bound')
 
142
        self.assertEqualDiff(
 
143
"""Location:
 
144
       checkout root: %s
 
145
  checkout of branch: %s
 
146
 
 
147
Related branches:
 
148
  parent branch: %s
 
149
 
 
150
Format:
 
151
       control: Meta directory format 1
 
152
  working tree: %s
 
153
        branch: Branch format 5
 
154
    repository: %s
 
155
 
 
156
In the working tree:
 
157
         1 unchanged
 
158
         0 modified
 
159
         0 added
 
160
         0 removed
 
161
         0 renamed
 
162
         1 unknown
 
163
         0 ignored
 
164
         0 versioned subdirectories
 
165
 
 
166
Branch history:
 
167
         1 revision
 
168
         0 days old
 
169
   first revision: %s
 
170
  latest revision: %s
 
171
 
 
172
Revision store:
 
173
         1 revision
 
174
         %d KiB
 
175
""" % (branch3.bzrdir.root_transport.base,
 
176
       branch1.bzrdir.root_transport.base,
 
177
       branch1.bzrdir.root_transport.base,
 
178
       bound_tree._format.get_format_description(),      
 
179
       branch3.repository._format.get_format_description(),
 
180
       datestring_first, datestring_first,
 
181
       # poking at _revision_store isn't all that clean, but neither is
 
182
       # having the ui test dependent on the exact overhead of a given store.
 
183
       branch3.repository._revision_store.total_size(
 
184
        branch3.repository.get_transaction())[1] / 1024,
 
185
       ), out)
 
186
        self.assertEqual('', err)
 
187
 
 
188
        # Checkout standalone (same as above, but does not have parent set)
 
189
        branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
 
190
            format=knit1_format)
 
191
        branch4.bind(branch1)
 
192
        branch4.bzrdir.open_workingtree().update()
 
193
        out, err = self.runbzr('info checkout --verbose')
 
194
        self.assertEqualDiff(
 
195
"""Location:
 
196
       checkout root: %s
 
197
  checkout of branch: %s
 
198
 
 
199
Format:
 
200
       control: Meta directory format 1
 
201
  working tree: Working tree format 3
 
202
        branch: Branch format 5
 
203
    repository: %s
 
204
 
 
205
In the working tree:
 
206
         1 unchanged
 
207
         0 modified
 
208
         0 added
 
209
         0 removed
 
210
         0 renamed
 
211
         0 unknown
 
212
         0 ignored
 
213
         0 versioned subdirectories
 
214
 
 
215
Branch history:
 
216
         1 revision
 
217
         1 committer
 
218
         0 days old
 
219
   first revision: %s
 
220
  latest revision: %s
 
221
 
 
222
Revision store:
 
223
         1 revision
 
224
         %d KiB
 
225
""" % (branch4.bzrdir.root_transport.base,
 
226
       branch1.bzrdir.root_transport.base,
 
227
       branch4.repository._format.get_format_description(),
 
228
       datestring_first, datestring_first,
 
229
       # poking at _revision_store isn't all that clean, but neither is
 
230
       # having the ui test dependent on the exact overhead of a given store.
 
231
       branch4.repository._revision_store.total_size(
 
232
        branch4.repository.get_transaction())[1] / 1024,
 
233
       ), out)
 
234
        self.assertEqual('', err)
 
235
 
 
236
        # Lightweight checkout (same as above, different branch and repository)
 
237
        tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
 
238
        branch5 = tree5.branch
 
239
        out, err = self.runbzr('info lightcheckout')
 
240
        self.assertEqualDiff(
 
241
"""Location:
 
242
 light checkout root: %s
 
243
  checkout of branch: %s
 
244
 
 
245
Format:
 
246
       control: Meta directory format 1
 
247
  working tree: Working tree format 3
 
248
        branch: Branch format 4
 
249
    repository: Weave repository format 6
 
250
 
 
251
In the working tree:
 
252
         1 unchanged
 
253
         0 modified
 
254
         0 added
 
255
         0 removed
 
256
         0 renamed
 
257
         0 unknown
 
258
         0 ignored
 
259
         0 versioned subdirectories
 
260
 
 
261
Branch history:
 
262
         1 revision
 
263
         0 days old
 
264
   first revision: %s
 
265
  latest revision: %s
 
266
 
 
267
Revision store:
 
268
         1 revision
 
269
         0 KiB
 
270
""" % (tree5.bzrdir.root_transport.base,
 
271
       branch1.bzrdir.root_transport.base,
 
272
       datestring_first, datestring_first,
 
273
       ), out)
 
274
        self.assertEqual('', err)
 
275
 
 
276
        # Update initial standalone branch
 
277
        self.build_tree(['standalone/b'])
 
278
        tree1.add('b')
 
279
        tree1.commit('commit two')
 
280
        rev = branch1.repository.get_revision(branch1.revision_history()[-1])
 
281
        datestring_last = format_date(rev.timestamp, rev.timezone)
 
282
 
 
283
        # Out of date branched standalone branch will not be detected
 
284
        out, err = self.runbzr('info branch')
 
285
        self.assertEqualDiff(
 
286
"""Location:
 
287
  branch root: %s
 
288
 
 
289
Related branches:
 
290
      parent branch: %s
 
291
  publish to branch: %s
 
292
 
 
293
Format:
 
294
       control: All-in-one format 6
 
295
  working tree: Working tree format 2
 
296
        branch: Branch format 4
 
297
    repository: Weave repository format 6
 
298
 
 
299
In the working tree:
 
300
         1 unchanged
 
301
         0 modified
 
302
         0 added
 
303
         0 removed
 
304
         0 renamed
 
305
         0 unknown
 
306
         0 ignored
 
307
         0 versioned subdirectories
 
308
 
 
309
Branch history:
 
310
         1 revision
 
311
         0 days old
 
312
   first revision: %s
 
313
  latest revision: %s
 
314
 
 
315
Revision store:
 
316
         1 revision
 
317
         0 KiB
 
318
""" % (branch2.bzrdir.root_transport.base,
 
319
       branch1.bzrdir.root_transport.base,
 
320
       branch1.bzrdir.root_transport.base,
 
321
       datestring_first, datestring_first,
 
322
       ), out)
 
323
        self.assertEqual('', err)
 
324
 
 
325
        # Out of date bound branch
 
326
        out, err = self.runbzr('info bound')
 
327
        self.assertEqualDiff(
 
328
"""Location:
 
329
       checkout root: %s
 
330
  checkout of branch: %s
 
331
 
 
332
Related branches:
 
333
  parent branch: %s
 
334
 
 
335
Format:
 
336
       control: Meta directory format 1
 
337
  working tree: Working tree format 3
 
338
        branch: Branch format 5
 
339
    repository: %s
 
340
 
 
341
Branch is out of date: missing 1 revision.
 
342
 
 
343
In the working tree:
 
344
         1 unchanged
 
345
         0 modified
 
346
         0 added
 
347
         0 removed
 
348
         0 renamed
 
349
         1 unknown
 
350
         0 ignored
 
351
         0 versioned subdirectories
 
352
 
 
353
Branch history:
 
354
         1 revision
 
355
         0 days old
 
356
   first revision: %s
 
357
  latest revision: %s
 
358
 
 
359
Revision store:
 
360
         1 revision
 
361
         %d KiB
 
362
""" % (branch3.bzrdir.root_transport.base,
 
363
       branch1.bzrdir.root_transport.base,
 
364
       branch1.bzrdir.root_transport.base,
 
365
       branch3.repository._format.get_format_description(),
 
366
       datestring_first, datestring_first,
 
367
       # poking at _revision_store isn't all that clean, but neither is
 
368
       # having the ui test dependent on the exact overhead of a given store.
 
369
       branch3.repository._revision_store.total_size(
 
370
        branch3.repository.get_transaction())[1] / 1024,
 
371
       ), out)
 
372
        self.assertEqual('', err)
 
373
 
 
374
        # Out of date checkout
 
375
        out, err = self.runbzr('info checkout')
 
376
        self.assertEqualDiff(
 
377
"""Location:
 
378
       checkout root: %s
 
379
  checkout of branch: %s
 
380
 
 
381
Format:
 
382
       control: Meta directory format 1
 
383
  working tree: Working tree format 3
 
384
        branch: Branch format 5
 
385
    repository: %s
 
386
 
 
387
Branch is out of date: missing 1 revision.
 
388
 
 
389
In the working tree:
 
390
         1 unchanged
 
391
         0 modified
 
392
         0 added
 
393
         0 removed
 
394
         0 renamed
 
395
         0 unknown
 
396
         0 ignored
 
397
         0 versioned subdirectories
 
398
 
 
399
Branch history:
 
400
         1 revision
 
401
         0 days old
 
402
   first revision: %s
 
403
  latest revision: %s
 
404
 
 
405
Revision store:
 
406
         1 revision
 
407
         %d KiB
 
408
""" % (branch4.bzrdir.root_transport.base,
 
409
       branch1.bzrdir.root_transport.base,
 
410
       branch4.repository._format.get_format_description(),
 
411
       datestring_first, datestring_first,
 
412
       # poking at _revision_store isn't all that clean, but neither is
 
413
       # having the ui test dependent on the exact overhead of a given store.
 
414
       branch4.repository._revision_store.total_size(
 
415
        branch4.repository.get_transaction())[1] / 1024,
 
416
       ), out)
 
417
        self.assertEqual('', err)
 
418
 
 
419
        # Out of date lightweight checkout
 
420
        out, err = self.runbzr('info lightcheckout --verbose')
 
421
        self.assertEqualDiff(
 
422
"""Location:
 
423
 light checkout root: %s
 
424
  checkout of branch: %s
 
425
 
 
426
Format:
 
427
       control: Meta directory format 1
 
428
  working tree: Working tree format 3
 
429
        branch: Branch format 4
 
430
    repository: Weave repository format 6
 
431
 
 
432
Working tree is out of date: missing 1 revision.
 
433
 
 
434
In the working tree:
 
435
         1 unchanged
 
436
         0 modified
 
437
         0 added
 
438
         0 removed
 
439
         0 renamed
 
440
         0 unknown
 
441
         0 ignored
 
442
         0 versioned subdirectories
 
443
 
 
444
Branch history:
 
445
         2 revisions
 
446
         1 committer
 
447
         0 days old
 
448
   first revision: %s
 
449
  latest revision: %s
 
450
 
 
451
Revision store:
 
452
         2 revisions
 
453
         0 KiB
 
454
""" % (tree5.bzrdir.root_transport.base,
 
455
       branch1.bzrdir.root_transport.base,
 
456
       datestring_first, datestring_last,
 
457
       ), out)
 
458
        self.assertEqual('', err)
 
459
 
 
460
    def test_info_standalone_no_tree(self):
 
461
        # create standalone branch without a working tree
 
462
        format = bzrdir.format_registry.make_bzrdir('default')
 
463
        branch = self.make_branch('branch')
 
464
        repo = branch.repository
 
465
        out, err = self.runbzr('info branch')
 
466
        self.assertEqualDiff(
 
467
"""Location:
 
468
  branch root: %s
 
469
 
 
470
Format:
 
471
       control: Meta directory format 1
 
472
        branch: Branch format 5
 
473
    repository: %s
 
474
 
 
475
Branch history:
 
476
         0 revisions
 
477
 
 
478
Revision store:
 
479
         0 revisions
 
480
         0 KiB
 
481
""" % (branch.bzrdir.root_transport.base,
 
482
       format.repository_format.get_format_description(),
 
483
       ), out)
 
484
        self.assertEqual('', err)
 
485
 
 
486
    def test_info_shared_repository(self):
 
487
        format = bzrdir.format_registry.make_bzrdir('knit')
 
488
        transport = self.get_transport()
 
489
 
 
490
        # Create shared repository
 
491
        repo = self.make_repository('repo', shared=True, format=format)
 
492
        repo.set_make_working_trees(False)
 
493
        out, err = self.runbzr('info repo')
 
494
        self.assertEqualDiff(
 
495
"""Location:
 
496
  shared repository: %s
 
497
 
 
498
Format:
 
499
       control: Meta directory format 1
 
500
    repository: %s
 
501
 
 
502
Revision store:
 
503
         0 revisions
 
504
         0 KiB
 
505
""" % (repo.bzrdir.root_transport.base,
 
506
       format.repository_format.get_format_description(),
 
507
       ), out)
 
508
        self.assertEqual('', err)
 
509
 
 
510
        # Create branch inside shared repository
 
511
        repo.bzrdir.root_transport.mkdir('branch')
 
512
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
 
513
            format=format)
 
514
        out, err = self.runbzr('info repo/branch')
 
515
        self.assertEqualDiff(
 
516
"""Location:
 
517
  shared repository: %s
 
518
  repository branch: branch
 
519
 
 
520
Format:
 
521
       control: Meta directory format 1
 
522
        branch: Branch format 5
 
523
    repository: %s
 
524
 
 
525
Branch history:
 
526
         0 revisions
 
527
 
 
528
Revision store:
 
529
         0 revisions
 
530
         0 KiB
 
531
""" % (repo.bzrdir.root_transport.base,
 
532
       format.repository_format.get_format_description(),
 
533
       ), out)
 
534
        self.assertEqual('', err)
 
535
 
 
536
        # Create lightweight checkout
 
537
        transport.mkdir('tree')
 
538
        transport.mkdir('tree/lightcheckout')
 
539
        tree2 = branch1.create_checkout('tree/lightcheckout', 
 
540
            lightweight=True)
 
541
        branch2 = tree2.branch
 
542
        self.assertCheckoutStatusOutput('tree/lightcheckout', tree2, 
 
543
                   shared_repo=repo)
 
544
 
 
545
        # Create normal checkout
 
546
        tree3 = branch1.create_checkout('tree/checkout')
 
547
        self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
 
548
            verbose=True,
 
549
            light_checkout=False, repo_branch=branch1)
 
550
        # Update lightweight checkout
 
551
        self.build_tree(['tree/lightcheckout/a'])
 
552
        tree2.add('a')
 
553
        tree2.commit('commit one')
 
554
        rev = repo.get_revision(branch2.revision_history()[0])
 
555
        datestring_first = format_date(rev.timestamp, rev.timezone)
 
556
        out, err = self.runbzr('info tree/lightcheckout --verbose')
 
557
        self.assertEqualDiff(
 
558
"""Location:
 
559
 light checkout root: %s
 
560
   shared repository: %s
 
561
   repository branch: branch
 
562
 
 
563
Format:
 
564
       control: Meta directory format 1
 
565
  working tree: Working tree format 3
 
566
        branch: Branch format 5
 
567
    repository: %s
 
568
 
 
569
In the working tree:
 
570
         1 unchanged
 
571
         0 modified
 
572
         0 added
 
573
         0 removed
 
574
         0 renamed
 
575
         0 unknown
 
576
         0 ignored
 
577
         0 versioned subdirectories
 
578
 
 
579
Branch history:
 
580
         1 revision
 
581
         1 committer
 
582
         0 days old
 
583
   first revision: %s
 
584
  latest revision: %s
 
585
 
 
586
Revision store:
 
587
         1 revision
 
588
         %d KiB
 
589
""" % (tree2.bzrdir.root_transport.base,
 
590
       repo.bzrdir.root_transport.base,
 
591
       format.repository_format.get_format_description(),
 
592
       datestring_first, datestring_first,
 
593
       # poking at _revision_store isn't all that clean, but neither is
 
594
       # having the ui test dependent on the exact overhead of a given store.
 
595
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
 
596
       ), out)
 
597
        self.assertEqual('', err)
 
598
 
 
599
        # Out of date checkout
 
600
        out, err = self.runbzr('info tree/checkout')
 
601
        self.assertEqualDiff(
 
602
"""Location:
 
603
       checkout root: %s
 
604
  checkout of branch: %s
 
605
 
 
606
Format:
 
607
       control: Meta directory format 1
 
608
  working tree: Working tree format 3
 
609
        branch: Branch format 5
 
610
    repository: %s
 
611
 
 
612
Branch is out of date: missing 1 revision.
 
613
 
 
614
In the working tree:
 
615
         0 unchanged
 
616
         0 modified
 
617
         0 added
 
618
         0 removed
 
619
         0 renamed
 
620
         0 unknown
 
621
         0 ignored
 
622
         0 versioned subdirectories
 
623
 
 
624
Branch history:
 
625
         0 revisions
 
626
 
 
627
Revision store:
 
628
         0 revisions
 
629
         0 KiB
 
630
""" % (tree3.bzrdir.root_transport.base,
 
631
       branch1.bzrdir.root_transport.base,
 
632
       format.repository_format.get_format_description(),
 
633
       ), out)
 
634
        self.assertEqual('', err)
 
635
 
 
636
        # Update checkout
 
637
        tree3.update()
 
638
        self.build_tree(['tree/checkout/b'])
 
639
        tree3.add('b')
 
640
        out, err = self.runbzr('info tree/checkout --verbose')
 
641
        self.assertEqualDiff(
 
642
"""Location:
 
643
       checkout root: %s
 
644
  checkout of branch: %s
 
645
 
 
646
Format:
 
647
       control: Meta directory format 1
 
648
  working tree: Working tree format 3
 
649
        branch: Branch format 5
 
650
    repository: %s
 
651
 
 
652
In the working tree:
 
653
         1 unchanged
 
654
         0 modified
 
655
         1 added
 
656
         0 removed
 
657
         0 renamed
 
658
         0 unknown
 
659
         0 ignored
 
660
         0 versioned subdirectories
 
661
 
 
662
Branch history:
 
663
         1 revision
 
664
         1 committer
 
665
         0 days old
 
666
   first revision: %s
 
667
  latest revision: %s
 
668
 
 
669
Revision store:
 
670
         1 revision
 
671
         %d KiB
 
672
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
 
673
       format.repository_format.get_format_description(),
 
674
       datestring_first, datestring_first,
 
675
       # poking at _revision_store isn't all that clean, but neither is
 
676
       # having the ui test dependent on the exact overhead of a given store.
 
677
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
 
678
       ), out)
 
679
        self.assertEqual('', err)
 
680
        tree3.commit('commit two')
 
681
 
 
682
        # Out of date lightweight checkout
 
683
        rev = repo.get_revision(branch1.revision_history()[-1])
 
684
        datestring_last = format_date(rev.timestamp, rev.timezone)
 
685
        out, err = self.runbzr('info tree/lightcheckout --verbose')
 
686
        self.assertEqualDiff(
 
687
"""Location:
 
688
 light checkout root: %s
 
689
   shared repository: %s
 
690
   repository branch: branch
 
691
 
 
692
Format:
 
693
       control: Meta directory format 1
 
694
  working tree: Working tree format 3
 
695
        branch: Branch format 5
 
696
    repository: %s
 
697
 
 
698
Working tree is out of date: missing 1 revision.
 
699
 
 
700
In the working tree:
 
701
         1 unchanged
 
702
         0 modified
 
703
         0 added
 
704
         0 removed
 
705
         0 renamed
 
706
         0 unknown
 
707
         0 ignored
 
708
         0 versioned subdirectories
 
709
 
 
710
Branch history:
 
711
         2 revisions
 
712
         1 committer
 
713
         0 days old
 
714
   first revision: %s
 
715
  latest revision: %s
 
716
 
 
717
Revision store:
 
718
         2 revisions
 
719
         %d KiB
 
720
""" % (tree2.bzrdir.root_transport.base,
 
721
       repo.bzrdir.root_transport.base,
 
722
       format.repository_format.get_format_description(),
 
723
       datestring_first, datestring_last,
 
724
       # poking at _revision_store isn't all that clean, but neither is
 
725
       # having the ui test dependent on the exact overhead of a given store.
 
726
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
 
727
       ), out)
 
728
        self.assertEqual('', err)
 
729
 
 
730
        # Show info about shared branch
 
731
        out, err = self.runbzr('info repo/branch --verbose')
 
732
        self.assertEqualDiff(
 
733
"""Location:
 
734
  shared repository: %s
 
735
  repository branch: branch
 
736
 
 
737
Format:
 
738
       control: Meta directory format 1
 
739
        branch: Branch format 5
 
740
    repository: %s
 
741
 
 
742
Branch history:
 
743
         2 revisions
 
744
         1 committer
 
745
         0 days old
 
746
   first revision: %s
 
747
  latest revision: %s
 
748
 
 
749
Revision store:
 
750
         2 revisions
 
751
         %d KiB
 
752
""" % (repo.bzrdir.root_transport.base,
 
753
       format.repository_format.get_format_description(),
 
754
       datestring_first, datestring_last,
 
755
       # poking at _revision_store isn't all that clean, but neither is
 
756
       # having the ui test dependent on the exact overhead of a given store.
 
757
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
 
758
       ), out)
 
759
        self.assertEqual('', err)
 
760
 
 
761
        # Show info about repository with revisions
 
762
        out, err = self.runbzr('info repo')
 
763
        self.assertEqualDiff(
 
764
"""Location:
 
765
  shared repository: %s
 
766
 
 
767
Format:
 
768
       control: Meta directory format 1
 
769
    repository: %s
 
770
 
 
771
Revision store:
 
772
         2 revisions
 
773
         %d KiB
 
774
""" % (repo.bzrdir.root_transport.base,
 
775
       format.repository_format.get_format_description(),
 
776
       # poking at _revision_store isn't all that clean, but neither is
 
777
       # having the ui test dependent on the exact overhead of a given store.
 
778
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
 
779
       ), out)
 
780
        self.assertEqual('', err)
 
781
 
 
782
    def test_info_shared_repository_with_trees(self):
 
783
        format = bzrdir.format_registry.make_bzrdir('knit')
 
784
        transport = self.get_transport()
 
785
 
 
786
        # Create shared repository with working trees
 
787
        repo = self.make_repository('repo', shared=True, format=format)
 
788
        repo.set_make_working_trees(True)
 
789
        out, err = self.runbzr('info repo')
 
790
        self.assertEqualDiff(
 
791
"""Location:
 
792
  shared repository: %s
 
793
 
 
794
Format:
 
795
       control: Meta directory format 1
 
796
    repository: %s
 
797
 
 
798
Create working tree for new branches inside the repository.
 
799
 
 
800
Revision store:
 
801
         0 revisions
 
802
         0 KiB
 
803
""" % (repo.bzrdir.root_transport.base,
 
804
       format.repository_format.get_format_description(),
 
805
       ), out)
 
806
        self.assertEqual('', err)
 
807
 
 
808
        # Create two branches
 
809
        repo.bzrdir.root_transport.mkdir('branch1')
 
810
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
 
811
            format=format)
 
812
        branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
 
813
 
 
814
        # Empty first branch
 
815
        out, err = self.runbzr('info repo/branch1 --verbose')
 
816
        self.assertEqualDiff(
 
817
"""Location:
 
818
    shared repository: %s
 
819
  repository checkout: branch1
 
820
 
 
821
Format:
 
822
       control: Meta directory format 1
 
823
  working tree: Working tree format 3
 
824
        branch: Branch format 5
 
825
    repository: %s
 
826
 
 
827
In the working tree:
 
828
         0 unchanged
 
829
         0 modified
 
830
         0 added
 
831
         0 removed
 
832
         0 renamed
 
833
         0 unknown
 
834
         0 ignored
 
835
         0 versioned subdirectories
 
836
 
 
837
Branch history:
 
838
         0 revisions
 
839
         0 committers
 
840
 
 
841
Revision store:
 
842
         0 revisions
 
843
         0 KiB
 
844
""" % (repo.bzrdir.root_transport.base,
 
845
       format.repository_format.get_format_description(),
 
846
       ), out)
 
847
        self.assertEqual('', err)
 
848
 
 
849
        # Update first branch
 
850
        self.build_tree(['repo/branch1/a'])
 
851
        tree1 = branch1.bzrdir.open_workingtree()
 
852
        tree1.add('a')
 
853
        tree1.commit('commit one')
 
854
        rev = repo.get_revision(branch1.revision_history()[0])
 
855
        datestring_first = format_date(rev.timestamp, rev.timezone)
 
856
        out, err = self.runbzr('info repo/branch1')
 
857
        self.assertEqualDiff(
 
858
"""Location:
 
859
    shared repository: %s
 
860
  repository checkout: branch1
 
861
 
 
862
Format:
 
863
       control: Meta directory format 1
 
864
  working tree: Working tree format 3
 
865
        branch: Branch format 5
 
866
    repository: %s
 
867
 
 
868
In the working tree:
 
869
         1 unchanged
 
870
         0 modified
 
871
         0 added
 
872
         0 removed
 
873
         0 renamed
 
874
         0 unknown
 
875
         0 ignored
 
876
         0 versioned subdirectories
 
877
 
 
878
Branch history:
 
879
         1 revision
 
880
         0 days old
 
881
   first revision: %s
 
882
  latest revision: %s
 
883
 
 
884
Revision store:
 
885
         1 revision
 
886
         %d KiB
 
887
""" % (repo.bzrdir.root_transport.base,
 
888
       format.repository_format.get_format_description(),
 
889
       datestring_first, datestring_first,
 
890
       # poking at _revision_store isn't all that clean, but neither is
 
891
       # having the ui test dependent on the exact overhead of a given store.
 
892
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
 
893
       ), out)
 
894
        self.assertEqual('', err)
 
895
 
 
896
        # Out of date second branch
 
897
        out, err = self.runbzr('info repo/branch2 --verbose')
 
898
        self.assertEqualDiff(
 
899
"""Location:
 
900
    shared repository: %s
 
901
  repository checkout: branch2
 
902
 
 
903
Related branches:
 
904
  parent branch: %s
 
905
 
 
906
Format:
 
907
       control: Meta directory format 1
 
908
  working tree: Working tree format 3
 
909
        branch: Branch format 5
 
910
    repository: %s
 
911
 
 
912
In the working tree:
 
913
         0 unchanged
 
914
         0 modified
 
915
         0 added
 
916
         0 removed
 
917
         0 renamed
 
918
         0 unknown
 
919
         0 ignored
 
920
         0 versioned subdirectories
 
921
 
 
922
Branch history:
 
923
         0 revisions
 
924
         0 committers
 
925
 
 
926
Revision store:
 
927
         1 revision
 
928
         %d KiB
 
929
""" % (repo.bzrdir.root_transport.base,
 
930
       branch1.bzrdir.root_transport.base,
 
931
       format.repository_format.get_format_description(),
 
932
       # poking at _revision_store isn't all that clean, but neither is
 
933
       # having the ui test dependent on the exact overhead of a given store.
 
934
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
 
935
       ), out)
 
936
        self.assertEqual('', err)
 
937
 
 
938
        # Update second branch
 
939
        tree2 = branch2.bzrdir.open_workingtree()
 
940
        tree2.pull(branch1)
 
941
        out, err = self.runbzr('info repo/branch2')
 
942
        self.assertEqualDiff(
 
943
"""Location:
 
944
    shared repository: %s
 
945
  repository checkout: branch2
 
946
 
 
947
Related branches:
 
948
  parent branch: %s
 
949
 
 
950
Format:
 
951
       control: Meta directory format 1
 
952
  working tree: Working tree format 3
 
953
        branch: Branch format 5
 
954
    repository: %s
 
955
 
 
956
In the working tree:
 
957
         1 unchanged
 
958
         0 modified
 
959
         0 added
 
960
         0 removed
 
961
         0 renamed
 
962
         0 unknown
 
963
         0 ignored
 
964
         0 versioned subdirectories
 
965
 
 
966
Branch history:
 
967
         1 revision
 
968
         0 days old
 
969
   first revision: %s
 
970
  latest revision: %s
 
971
 
 
972
Revision store:
 
973
         1 revision
 
974
         %d KiB
 
975
""" % (repo.bzrdir.root_transport.base,
 
976
       branch1.bzrdir.root_transport.base,
 
977
       format.repository_format.get_format_description(),
 
978
       datestring_first, datestring_first,
 
979
       # poking at _revision_store isn't all that clean, but neither is
 
980
       # having the ui test dependent on the exact overhead of a given store.
 
981
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
 
982
       ), out)
 
983
        self.assertEqual('', err)
 
984
 
 
985
        # Show info about repository with revisions
 
986
        out, err = self.runbzr('info repo')
 
987
        self.assertEqualDiff(
 
988
"""Location:
 
989
  shared repository: %s
 
990
 
 
991
Format:
 
992
       control: Meta directory format 1
 
993
    repository: %s
 
994
 
 
995
Create working tree for new branches inside the repository.
 
996
 
 
997
Revision store:
 
998
         1 revision
 
999
         %d KiB
 
1000
""" % (repo.bzrdir.root_transport.base,
 
1001
       format.repository_format.get_format_description(),
 
1002
       # poking at _revision_store isn't all that clean, but neither is
 
1003
       # having the ui test dependent on the exact overhead of a given store.
 
1004
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
 
1005
       ),
 
1006
       out)
 
1007
        self.assertEqual('', err)
 
1008
    
 
1009
    def test_info_shared_repository_with_tree_in_root(self):
 
1010
        format = bzrdir.format_registry.make_bzrdir('knit')
 
1011
        transport = self.get_transport()
 
1012
 
 
1013
        # Create shared repository with working trees
 
1014
        repo = self.make_repository('repo', shared=True, format=format)
 
1015
        repo.set_make_working_trees(True)
 
1016
        out, err = self.runbzr('info repo')
 
1017
        self.assertEqualDiff(
 
1018
"""Location:
 
1019
  shared repository: %s
 
1020
 
 
1021
Format:
 
1022
       control: Meta directory format 1
 
1023
    repository: %s
 
1024
 
 
1025
Create working tree for new branches inside the repository.
 
1026
 
 
1027
Revision store:
 
1028
         0 revisions
 
1029
         0 KiB
 
1030
""" % (repo.bzrdir.root_transport.base,
 
1031
       format.repository_format.get_format_description(),
 
1032
       ), out)
 
1033
        self.assertEqual('', err)
 
1034
 
 
1035
        # Create branch in root of repository
 
1036
        control = repo.bzrdir
 
1037
        branch = control.create_branch()
 
1038
        control.create_workingtree()
 
1039
        out, err = self.runbzr('info repo')
 
1040
        self.assertEqualDiff(
 
1041
"""Location:
 
1042
    shared repository: %s
 
1043
  repository checkout: .
 
1044
 
 
1045
Format:
 
1046
       control: Meta directory format 1
 
1047
  working tree: Working tree format 3
 
1048
        branch: Branch format 5
 
1049
    repository: %s
 
1050
 
 
1051
In the working tree:
 
1052
         0 unchanged
 
1053
         0 modified
 
1054
         0 added
 
1055
         0 removed
 
1056
         0 renamed
 
1057
         0 unknown
 
1058
         0 ignored
 
1059
         0 versioned subdirectories
 
1060
 
 
1061
Branch history:
 
1062
         0 revisions
 
1063
 
 
1064
Revision store:
 
1065
         0 revisions
 
1066
         0 KiB
 
1067
""" % (repo.bzrdir.root_transport.base,
 
1068
       format.repository_format.get_format_description(),
 
1069
       ), out)
 
1070
        self.assertEqual('', err)
 
1071
 
 
1072
    def assertCheckoutStatusOutput(self, 
 
1073
        command_string, lco_tree, shared_repo=None,
 
1074
        repo_branch=None,
 
1075
        tree_locked=False,
 
1076
        branch_locked=False, repo_locked=False,
 
1077
        verbose=False,
 
1078
        light_checkout=True):
 
1079
        """Check the output of info in a light checkout tree.
 
1080
 
 
1081
        This is not quite a mirror of the info code: rather than using the
 
1082
        tree being examined to predict output, it uses a bunch of flags which
 
1083
        allow us, the test writers, to document what *should* be present in
 
1084
        the output. Removing this separation would remove the value of the
 
1085
        tests.
 
1086
        
 
1087
        :param path: the path to the light checkout.
 
1088
        :param lco_tree: the tree object for the light checkout.
 
1089
        :param shared_repo: A shared repository is in use, expect that in
 
1090
            the output.
 
1091
        :param repo_branch: A branch in a shared repository for non light
 
1092
            checkouts.
 
1093
        :param tree_locked: If true, expect the tree to be locked.
 
1094
        :param branch_locked: If true, expect the branch to be locked.
 
1095
        :param repo_locked: If true, expect the repository to be locked.
 
1096
        :param verbose: If true, expect verbose output
 
1097
        """
 
1098
        out, err = self.runbzr('info %s' % command_string)
 
1099
        if repo_locked or branch_locked or tree_locked:
 
1100
            def locked_message(a_bool):
 
1101
                if a_bool:
 
1102
                    return 'locked'
 
1103
                else:
 
1104
                    return 'unlocked'
 
1105
            expected_lock_output = (
 
1106
                "\n"
 
1107
                "Lock status:\n"
 
1108
                "  working tree: %s\n"
 
1109
                "        branch: %s\n"
 
1110
                "    repository: %s\n" % (
 
1111
                    locked_message(tree_locked),
 
1112
                    locked_message(branch_locked),
 
1113
                    locked_message(repo_locked)))
 
1114
        else:
 
1115
            expected_lock_output = ''
 
1116
        if light_checkout:
 
1117
            tree_data = (" light checkout root: %s" %
 
1118
                lco_tree.bzrdir.root_transport.base)
 
1119
        else:
 
1120
            tree_data = ("       checkout root: %s" %
 
1121
                lco_tree.bzrdir.root_transport.base)
 
1122
        if shared_repo is not None:
 
1123
            branch_data = (
 
1124
                "   shared repository: %s\n"
 
1125
                "   repository branch: branch\n" %
 
1126
                shared_repo.bzrdir.root_transport.base)
 
1127
        elif repo_branch is not None:
 
1128
            branch_data = (
 
1129
                "  checkout of branch: %s\n" % 
 
1130
                repo_branch.bzrdir.root_transport.base)
 
1131
        else:
 
1132
            branch_data = ("  checkout of branch: %s\n" % 
 
1133
                lco_tree.branch.bzrdir.root_transport.base)
 
1134
        
 
1135
        if verbose:
 
1136
            verbose_info = '         0 committers\n'
 
1137
        else:
 
1138
            verbose_info = ''
 
1139
            
 
1140
        self.assertEqualDiff(
 
1141
"""Location:
 
1142
%s
 
1143
%s
 
1144
Format:
 
1145
       control: Meta directory format 1
 
1146
  working tree: %s
 
1147
        branch: Branch format 5
 
1148
    repository: %s
 
1149
%s
 
1150
In the working tree:
 
1151
         0 unchanged
 
1152
         0 modified
 
1153
         0 added
 
1154
         0 removed
 
1155
         0 renamed
 
1156
         0 unknown
 
1157
         0 ignored
 
1158
         0 versioned subdirectories
 
1159
 
 
1160
Branch history:
 
1161
         0 revisions
 
1162
%s
 
1163
Revision store:
 
1164
         0 revisions
 
1165
         0 KiB
 
1166
""" %  (tree_data,
 
1167
        branch_data,
 
1168
        lco_tree._format.get_format_description(),
 
1169
        lco_tree.branch.repository._format.get_format_description(),
 
1170
        expected_lock_output,
 
1171
        verbose_info,
 
1172
        ), out)
 
1173
        self.assertEqual('', err)
 
1174
 
 
1175
    def test_info_locking(self):
 
1176
        transport = self.get_transport()
 
1177
        # Create shared repository with a branch
 
1178
        repo = self.make_repository('repo', shared=True,
 
1179
                                    format=bzrlib.bzrdir.BzrDirMetaFormat1())
 
1180
        repo.set_make_working_trees(False)
 
1181
        repo.bzrdir.root_transport.mkdir('branch')
 
1182
        repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
 
1183
                                    format=bzrlib.bzrdir.BzrDirMetaFormat1())
 
1184
        # Do a heavy checkout
 
1185
        transport.mkdir('tree')
 
1186
        transport.mkdir('tree/checkout')
 
1187
        co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
 
1188
            format=bzrlib.bzrdir.BzrDirMetaFormat1())
 
1189
        co_branch.bind(repo_branch)
 
1190
        # Do a light checkout of the heavy one
 
1191
        transport.mkdir('tree/lightcheckout')
 
1192
        lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
 
1193
        bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
 
1194
        lco_dir.create_workingtree()
 
1195
        lco_tree = lco_dir.open_workingtree()
 
1196
 
 
1197
        # Test all permutations of locking the working tree, branch and repository
 
1198
        # W B R
 
1199
 
 
1200
        # U U U
 
1201
        self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
 
1202
        # U U L
 
1203
        lco_tree.branch.repository.lock_write()
 
1204
        try:
 
1205
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1206
            lco_tree,
 
1207
            repo_locked=True)
 
1208
        finally:
 
1209
            lco_tree.branch.repository.unlock()
 
1210
        # U L L
 
1211
        lco_tree.branch.lock_write()
 
1212
        try:
 
1213
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1214
            lco_tree,
 
1215
            branch_locked=True,
 
1216
            repo_locked=True)
 
1217
        finally:
 
1218
            lco_tree.branch.unlock()
 
1219
        # L L L
 
1220
        lco_tree.lock_write()
 
1221
        try:
 
1222
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1223
            lco_tree,
 
1224
            tree_locked=True,
 
1225
            branch_locked=True,
 
1226
            repo_locked=True)
 
1227
        finally:
 
1228
            lco_tree.unlock()
 
1229
        # L L U
 
1230
        lco_tree.lock_write()
 
1231
        lco_tree.branch.repository.unlock()
 
1232
        try:
 
1233
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1234
            lco_tree,
 
1235
            tree_locked=True,
 
1236
            branch_locked=True)
 
1237
        finally:
 
1238
            lco_tree.branch.repository.lock_write()
 
1239
            lco_tree.unlock()
 
1240
        # L U U
 
1241
        lco_tree.lock_write()
 
1242
        lco_tree.branch.unlock()
 
1243
        try:
 
1244
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1245
            lco_tree,
 
1246
            tree_locked=True)
 
1247
        finally:
 
1248
            lco_tree.branch.lock_write()
 
1249
            lco_tree.unlock()
 
1250
        # L U L
 
1251
        lco_tree.lock_write()
 
1252
        lco_tree.branch.unlock()
 
1253
        lco_tree.branch.repository.lock_write()
 
1254
        try:
 
1255
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1256
            lco_tree,
 
1257
            tree_locked=True,
 
1258
            repo_locked=True)
 
1259
        finally:
 
1260
            lco_tree.branch.repository.unlock()
 
1261
            lco_tree.branch.lock_write()
 
1262
            lco_tree.unlock()
 
1263
        # U L U
 
1264
        lco_tree.branch.lock_write()
 
1265
        lco_tree.branch.repository.unlock()
 
1266
        try:
 
1267
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1268
            lco_tree,
 
1269
            branch_locked=True)
 
1270
        finally:
 
1271
            lco_tree.branch.repository.lock_write()
 
1272
            lco_tree.branch.unlock()
 
1273
 
 
1274
    def test_info_locking_oslocks(self):
 
1275
        if sys.platform == "win32":
 
1276
            raise TestSkipped("don't use oslocks on win32 in unix manner")
 
1277
 
 
1278
        tree = self.make_branch_and_tree('branch',
 
1279
                                         format=bzrlib.bzrdir.BzrDirFormat6())
 
1280
 
 
1281
        # Test all permutations of locking the working tree, branch and repository
 
1282
        # XXX: Well not yet, as we can't query oslocks yet. Currently, it's
 
1283
        # implemented by raising NotImplementedError and get_physical_lock_status()
 
1284
        # always returns false. This makes bzr info hide the lock status.  (Olaf)
 
1285
        # W B R
 
1286
 
 
1287
        # U U U
 
1288
        out, err = self.runbzr('info branch')
 
1289
        self.assertEqualDiff(
 
1290
"""Location:
 
1291
  branch root: %s
 
1292
 
 
1293
Format:
 
1294
       control: All-in-one format 6
 
1295
  working tree: Working tree format 2
 
1296
        branch: Branch format 4
 
1297
    repository: %s
 
1298
 
 
1299
In the working tree:
 
1300
         0 unchanged
 
1301
         0 modified
 
1302
         0 added
 
1303
         0 removed
 
1304
         0 renamed
 
1305
         0 unknown
 
1306
         0 ignored
 
1307
         0 versioned subdirectories
 
1308
 
 
1309
Branch history:
 
1310
         0 revisions
 
1311
 
 
1312
Revision store:
 
1313
         0 revisions
 
1314
         0 KiB
 
1315
""" % (tree.bzrdir.root_transport.base,
 
1316
       tree.branch.repository._format.get_format_description(),
 
1317
       ), out)
 
1318
        self.assertEqual('', err)
 
1319
        # L L L
 
1320
        tree.lock_write()
 
1321
        out, err = self.runbzr('info branch')
 
1322
        self.assertEqualDiff(
 
1323
"""Location:
 
1324
  branch root: %s
 
1325
 
 
1326
Format:
 
1327
       control: All-in-one format 6
 
1328
  working tree: Working tree format 2
 
1329
        branch: Branch format 4
 
1330
    repository: %s
 
1331
 
 
1332
In the working tree:
 
1333
         0 unchanged
 
1334
         0 modified
 
1335
         0 added
 
1336
         0 removed
 
1337
         0 renamed
 
1338
         0 unknown
 
1339
         0 ignored
 
1340
         0 versioned subdirectories
 
1341
 
 
1342
Branch history:
 
1343
         0 revisions
 
1344
 
 
1345
Revision store:
 
1346
         0 revisions
 
1347
         0 KiB
 
1348
""" % (tree.bzrdir.root_transport.base,
 
1349
       tree.branch.repository._format.get_format_description(),
 
1350
       ), out)
 
1351
        self.assertEqual('', err)
 
1352
        tree.unlock()