/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
1534.5.1 by Robert Collins
Give info some reasonable output and tests.
1
# Copyright (C) 2006 by Canonical Ltd
2
# -*- coding: utf-8 -*-
3
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
8
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
18
19
"""Tests for the info command of bzr."""
20
21
22
from bzrlib.osutils import format_date
23
from bzrlib.tests import TestSkipped
24
from bzrlib.tests.blackbox import ExternalBase
25
26
27
class TestInfo(ExternalBase):
28
29
    def test_info_standalone_trivial(self):
30
        self.runbzr("init")
31
        out, err = self.runbzr('info')
32
        self.assertEqualDiff(
33
"""branch format: Bazaar-NG branch, format 6
34
35
in the working tree:
36
         0 unchanged
37
         0 modified
38
         0 added
39
         0 removed
40
         0 renamed
41
         0 unknown
42
         0 ignored
43
         0 versioned subdirectories
44
45
branch history:
46
         0 revisions
47
         0 committers
48
49
revision store:
50
         0 revisions
51
         0 kB
52
""",
53
        out)
54
        self.assertEqual('', err)
55
56
    def test_info_up_to_date_checkout(self):
57
        a_branch = self.make_branch_and_tree('branch')
58
        self.runbzr('checkout branch checkout')
59
        out, err = self.runbzr('info checkout')
60
        self.assertEqualDiff(
61
"""working tree format: Bazaar-NG Working Tree format 3
62
branch location: %s
63
branch format: Bazaar-NG branch, format 6
64
65
in the working tree:
66
         0 unchanged
67
         0 modified
68
         0 added
69
         0 removed
70
         0 renamed
71
         0 unknown
72
         0 ignored
73
         0 versioned subdirectories
74
75
branch history:
76
         0 revisions
77
         0 committers
78
79
revision store:
80
         0 revisions
81
         0 kB
82
""" % a_branch.bzrdir.root_transport.base,
83
        out)
84
        self.assertEqual('', err)
85
86
    def test_info_out_of_date_standalone_tree(self):
87
        # FIXME the default format has to change for this to pass
88
        # because it currently uses the branch last-revision marker.
89
        raise TestSkipped('default format too old')
90
        self.make_branch_and_tree('branch')
91
        # make a checkout
92
        self.runbzr('checkout branch checkout')
93
        self.build_tree(['checkout/file'])
94
        self.runbzr('add checkout/file')
95
        self.runbzr('commit -m add-file checkout')
96
        # now branch should be out of date
97
        out,err = self.runbzr('update branch')
98
        self.assertEqualDiff(
99
"""branch format: Bazaar-NG branch, format 6
100
101
Working tree is out of date: missing 1 revision.
102
in the working tree:
103
         0 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
         0 revisions
114
         0 committers
115
116
revision store:
117
         0 revisions
118
         0 kB
119
""" % a_branch.bzrdir.root_transport.base,
120
        out)
121
        self.assertEqual('', err)
122
123
    def test_info_out_of_date_checkout(self):
124
        # note this deliberately uses a checkout at 'None' to 
125
        # test the out of date message with a revision notin the 
126
        # revision history.
127
        a_branch = self.make_branch('branch')
128
        # make two checkouts
129
        self.runbzr('checkout branch checkout')
130
        self.runbzr('checkout branch checkout2')
131
        self.build_tree(['checkout/file'])
132
        self.runbzr('add checkout/file')
133
        self.runbzr('commit -m add-file checkout')
134
        # now checkout2 should be out of date
135
        out,err = self.runbzr('info checkout2')
136
        rev = a_branch.repository.get_revision(a_branch.revision_history()[0])
137
        datestring = format_date(rev.timestamp, rev.timezone)
138
        self.assertEqualDiff(
139
"""working tree format: Bazaar-NG Working Tree format 3
140
branch location: %s
141
branch format: Bazaar-NG branch, format 6
142
143
Working tree is out of date: missing 1 revision.
144
in the working tree:
145
         0 unchanged
146
         0 modified
147
         0 added
148
         0 removed
149
         0 renamed
150
         0 unknown
151
         0 ignored
152
         0 versioned subdirectories
153
154
branch history:
155
         1 revision
156
         1 committer
157
         0 days old
158
   first revision: %s
159
  latest revision: %s
160
161
revision store:
162
         1 revision
163
         0 kB
164
""" % (a_branch.bzrdir.root_transport.base,
165
       datestring,
166
       datestring,
167
       ),
168
            out)
169
        self.assertEqual('', err)