~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_version_info.py

Merge version-info fixes for dotted revnos.

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
 
54
54
        return wt
55
55
 
 
56
    def create_tree_with_dotted_revno(self):
 
57
        wt = self.make_branch_and_tree('branch')
 
58
        self.build_tree(['branch/a'])
 
59
        wt.add('a')
 
60
        wt.commit('a', rev_id='r1')
 
61
 
 
62
        other = wt.bzrdir.sprout('other').open_workingtree()
 
63
        self.build_tree(['other/b.a'])
 
64
        other.add(['b.a'])
 
65
        other.commit('b.a', rev_id='o2')
 
66
 
 
67
        os.chdir('branch')
 
68
        self.run_bzr('merge ../other')
 
69
        wt.commit('merge', rev_id='merge')
 
70
 
 
71
        wt.update(revision='o2')
 
72
 
 
73
        return wt
 
74
 
56
75
    def test_rio_null(self):
57
76
        wt = self.make_branch_and_tree('branch')
58
77
 
63
82
        self.assertContainsRe(val, 'build-date:')
64
83
        self.assertContainsRe(val, 'revno: 0')
65
84
 
 
85
    def test_rio_dotted_revno(self):
 
86
        wt = self.create_tree_with_dotted_revno()
 
87
 
 
88
        sio = StringIO()
 
89
        builder = RioVersionInfoBuilder(wt.branch, working_tree=wt)
 
90
        builder.generate(sio)
 
91
        val = sio.getvalue()
 
92
        self.assertContainsRe(val, 'revno: 1.1.1')
 
93
 
66
94
    def test_rio_version_text(self):
67
95
        wt = self.create_branch()
68
96
 
191
219
        builder.generate(sio)
192
220
        val = sio.getvalue()
193
221
        self.assertContainsRe(val, "'revision_id': None")
194
 
        self.assertContainsRe(val, "'revno': 0")
 
222
        self.assertContainsRe(val, "'revno': '0'")
195
223
        self.assertNotContainsString(val, '\n\n\n\n')
196
224
 
 
225
    def test_python_dotted_revno(self):
 
226
        wt = self.create_tree_with_dotted_revno()
 
227
 
 
228
        sio = StringIO()
 
229
        builder = PythonVersionInfoBuilder(wt.branch, working_tree=wt)
 
230
        builder.generate(sio)
 
231
        val = sio.getvalue()
 
232
        self.assertContainsRe(val, "'revno': '1.1.1'")
 
233
 
197
234
    def test_python_version(self):
198
235
        wt = self.create_branch()
199
236
 
223
260
            return tvi
224
261
 
225
262
        tvi = regen()
226
 
        self.assertEqual(3, tvi.version_info['revno'])
 
263
        self.assertEqual('3', tvi.version_info['revno'])
227
264
        self.assertEqual('r3', tvi.version_info['revision_id'])
228
265
        self.assertTrue(tvi.version_info.has_key('date'))
229
266
        self.assertEqual(None, tvi.version_info['clean'])
283
320
        self.assertRaises(errors.MissingTemplateVariable, 
284
321
            builder.generate, sio)
285
322
 
 
323
    def test_custom_dotted_revno(self):
 
324
        sio = StringIO()
 
325
        wt = self.create_tree_with_dotted_revno()
 
326
        builder = CustomVersionInfoBuilder(wt.branch, working_tree=wt, 
 
327
            template='{revno} revid: {revision_id}')
 
328
        builder.generate(sio)
 
329
        self.assertEquals("1.1.1 revid: o2", sio.getvalue())
 
330
 
286
331
    def test_custom_version_text(self):
287
332
        wt = self.create_branch()
288
333