~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2007-03-01 21:56:19 UTC
  • mto: (2255.7.84 dirstate)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: john@arbash-meinel.com-20070301215619-wpt6kz8yem3ypu1b
Update to dirstate locking.
Move all of WT4.lock_* functions locally, so that they can
properly interact and cleanup around when we lock/unlock the
dirstate file.
Change all Lock objects to be non-blocking. So that if someone
grabs a lock on the DirState we find out immediately, rather
than blocking.
Change WT4.unlock() so that if the dirstate is dirty, it will
save the contents even if it only has a read lock.
It does this by trying to take a write lock, if it fails
we just ignore it. If it succeeds, then we can flush to disk.
This is more important now that DirState tracks file changes.
It allows 'bzr status' to update the cached stat and sha values.

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