/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 breezy/tests/test_version_info.py

  • Committer: Jelmer Vernooij
  • Date: 2018-04-02 00:52:27 UTC
  • mfrom: (6939 work)
  • mto: This revision was merged to the branch mainline in revision 7274.
  • Revision ID: jelmer@jelmer.uk-20180402005227-pecflp1mvdjrjqd6
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for version_info"""
18
18
 
19
 
import imp
20
19
import os
21
20
import sys
22
21
 
47
46
 
48
47
        self.build_tree(['branch/a'])
49
48
        wt.add('a')
50
 
        wt.commit('a', rev_id='r1')
 
49
        wt.commit('a', rev_id=b'r1')
51
50
 
52
51
        self.build_tree(['branch/b'])
53
52
        wt.add('b')
54
 
        wt.commit('b', rev_id='r2')
 
53
        wt.commit('b', rev_id=b'r2')
55
54
 
56
 
        self.build_tree_contents([('branch/a', 'new contents\n')])
57
 
        wt.commit(u'\xe52', rev_id='r3')
 
55
        self.build_tree_contents([('branch/a', b'new contents\n')])
 
56
        wt.commit(u'\xe52', rev_id=b'r3')
58
57
 
59
58
        return wt
60
59
 
62
61
        wt = self.make_branch_and_tree('branch')
63
62
        self.build_tree(['branch/a'])
64
63
        wt.add('a')
65
 
        wt.commit('a', rev_id='r1')
 
64
        wt.commit('a', rev_id=b'r1')
66
65
 
67
66
        other = wt.controldir.sprout('other').open_workingtree()
68
67
        self.build_tree(['other/b.a'])
69
68
        other.add(['b.a'])
70
 
        other.commit('b.a', rev_id='o2')
 
69
        other.commit('b.a', rev_id=b'o2')
71
70
 
72
71
        os.chdir('branch')
73
72
        self.run_bzr('merge ../other')
74
 
        wt.commit('merge', rev_id='merge')
 
73
        wt.commit('merge', rev_id=b'merge')
75
74
 
76
75
        wt.update(revision='o2')
77
76
 
214
213
        wt.add('c')
215
214
        wt.rename_one('b', 'd')
216
215
 
217
 
        wt.commit('modified', rev_id='r4')
 
216
        wt.commit('modified', rev_id=b'r4')
218
217
 
219
218
        wt.remove(['c', 'd'])
220
219
        os.remove('branch/d')
262
261
 
263
262
    def regen(self, wt, **kwargs):
264
263
        """Create a test module, import and return it"""
265
 
        outf = open('test_version_information.py', 'wb')
266
 
        try:
 
264
        with open('test_version_information.py', 'wb') as outf:
267
265
            builder = PythonVersionInfoBuilder(wt.branch, working_tree=wt,
268
266
                                               **kwargs)
269
267
            builder.generate(outf)
270
 
        finally:
271
 
            outf.close()
 
268
        import imp
272
269
        module_info = imp.find_module('test_version_information',
273
270
                                      [self.test_dir])
274
271
        tvi = imp.load_module('tvi', *module_info)
325
322
        self.assertEqual('new', tvi.file_revisions['c'])
326
323
        self.assertEqual('renamed from b', tvi.file_revisions['d'])
327
324
 
328
 
        wt.commit('modified', rev_id='r4')
 
325
        wt.commit('modified', rev_id=b'r4')
329
326
        wt.remove(['c', 'd'])
330
327
        os.remove('branch/d')
331
328
        tvi = self.regen(wt, check_for_clean=True, include_file_revisions=True)