~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testtestament.py

  • Committer: Robert Collins
  • Date: 2005-10-16 00:22:17 UTC
  • mto: This revision was merged to the branch mainline in revision 1457.
  • Revision ID: robertc@lifelesslap.robertcollins.net-20051016002217-aa38f9c1eb13ee48
Plugins are now loaded under bzrlib.plugins, not bzrlib.plugin.

Plugins are also made available for other plugins to use by making them 
accessible via import bzrlib.plugins.NAME. You should not import other
plugins during the __init__ of your plugin though, as no ordering is
guaranteed, and the plugins directory is not on the python path.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from sha import sha
23
23
import sys
24
24
 
25
 
from bzrlib.tests import TestCaseInTempDir
26
 
from bzrlib.tests.treeshape import build_tree_contents
 
25
from bzrlib.selftest import TestCaseInTempDir
 
26
from bzrlib.selftest.treeshape import build_tree_contents
27
27
from bzrlib.branch import Branch
28
28
from bzrlib.testament import Testament
29
29
from bzrlib.trace import mutter
30
30
from bzrlib.osutils import has_symlinks
31
31
 
32
 
 
33
32
class TestamentTests(TestCaseInTempDir):
34
 
 
35
33
    def setUp(self):
36
34
        super(TestamentTests, self).setUp()
37
35
        b = self.b = Branch.initialize('.')
38
 
        b.nick = "test branch"
39
 
        b.working_tree().commit(message='initial null commit',
 
36
        b.commit(message='initial null commit',
40
37
                 committer='test@user',
41
38
                 timestamp=1129025423, # 'Tue Oct 11 20:10:23 2005'
42
39
                 timezone=0,
44
41
        build_tree_contents([('hello', 'contents of hello file'),
45
42
                             ('src/', ),
46
43
                             ('src/foo.c', 'int main()\n{\n}\n')])
47
 
        b.working_tree().add(['hello', 'src', 'src/foo.c'],
48
 
                             ['hello-id', 'src-id', 'foo.c-id'])
49
 
        b.working_tree().commit(message='add files and directories',
 
44
        b.add(['hello', 'src', 'src/foo.c'],
 
45
              ['hello-id', 'src-id', 'foo.c-id'])
 
46
        b.commit(message='add files and directories',
50
47
                 timestamp=1129025483,
51
48
                 timezone=36000,
52
49
                 rev_id='test@user-2',
96
93
        if not has_symlinks():
97
94
            return
98
95
        os.symlink('wibble/linktarget', 'link')
99
 
        self.b.working_tree().add(['link'], ['link-id'])
100
 
        self.b.working_tree().commit(message='add symlink',
 
96
        self.b.add(['link'], ['link-id'])
 
97
        self.b.commit(message='add symlink',
101
98
                 timestamp=1129025493,
102
99
                 timezone=36000,
103
100
                 rev_id='test@user-3',
105
102
        t = Testament.from_revision(self.b, 'test@user-3')
106
103
        self.assertEqualDiff(t.as_text(), REV_3_TESTAMENT)
107
104
 
108
 
    def test_testament_revprops(self):
109
 
        """Testament to revision with extra properties"""
110
 
        props = dict(flavor='sour cherry\ncream cheese',
111
 
                     size='medium')
112
 
        self.b.working_tree().commit(message='revision with properties',
113
 
                      timestamp=1129025493,
114
 
                      timezone=36000,
115
 
                      rev_id='test@user-3',
116
 
                      committer='test@user',
117
 
                      revprops=props)
118
 
        t = Testament.from_revision(self.b, 'test@user-3')
119
 
        self.assertEqualDiff(t.as_text(), REV_PROPS_TESTAMENT)
120
 
 
121
 
    def test___init__(self):
122
 
        revision = self.b.get_revision('test@user-2')
123
 
        inventory = self.b.get_inventory('test@user-2')
124
 
        testament_1 = Testament(revision, inventory).as_short_text()
125
 
        testament_2 = Testament.from_revision(self.b, 
126
 
                                              'test@user-2').as_short_text()
127
 
        self.assertEqual(testament_1, testament_2)
128
 
                    
129
105
 
130
106
REV_1_TESTAMENT = """\
131
107
bazaar-ng testament version 1
137
113
message:
138
114
  initial null commit
139
115
inventory:
140
 
properties:
141
 
  branch-nick:
142
 
    test branch
143
116
"""
144
117
 
145
118
REV_1_SHORT = """\
163
136
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73
164
137
  directory src src-id
165
138
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24
166
 
properties:
167
 
  branch-nick:
168
 
    test branch
169
139
"""
170
140
 
171
141
 
176
146
""" % sha(REV_2_TESTAMENT).hexdigest()
177
147
 
178
148
 
179
 
REV_PROPS_TESTAMENT = """\
180
 
bazaar-ng testament version 1
181
 
revision-id: test@user-3
182
 
committer: test@user
183
 
timestamp: 1129025493
184
 
timezone: 36000
185
 
parents:
186
 
  test@user-2
187
 
message:
188
 
  revision with properties
189
 
inventory:
190
 
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73
191
 
  directory src src-id
192
 
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24
193
 
properties:
194
 
  branch-nick:
195
 
    test branch
196
 
  flavor:
197
 
    sour cherry
198
 
    cream cheese
199
 
  size:
200
 
    medium
201
 
"""
202
 
 
203
 
 
204
149
REV_3_TESTAMENT = """\
205
150
bazaar-ng testament version 1
206
151
revision-id: test@user-3
216
161
  symlink link link-id wibble/linktarget
217
162
  directory src src-id
218
163
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24
219
 
properties:
220
 
  branch-nick:
221
 
    test branch
222
164
"""