~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testinv.py

  • Committer: Robert Collins
  • Date: 2005-10-17 11:56:54 UTC
  • mfrom: (1185.16.59)
  • Revision ID: robertc@robertcollins.net-20051017115654-662239e1587524a8
mergeĀ fromĀ martin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
from bzrlib.inventory import Inventory, ROOT_ID
25
25
import bzrlib.inventory as inventory
26
26
from bzrlib.osutils import has_symlinks, rename
27
 
from bzrlib.tests import TestCase, TestCaseInTempDir
 
27
from bzrlib.selftest import TestCase, TestCaseInTempDir
28
28
 
29
29
 
30
30
class TestInventory(TestCase):
137
137
 
138
138
    def setUp(self):
139
139
        super(TestEntryDiffing, self).setUp()
140
 
        self.branch = Branch.initialize(u'.')
141
 
        self.wt = self.branch.working_tree()
 
140
        self.branch = Branch.initialize('.')
142
141
        print >> open('file', 'wb'), 'foo'
143
 
        self.branch.working_tree().add(['file'], ['fileid'])
 
142
        self.branch.add(['file'], ['fileid'])
144
143
        if has_symlinks():
145
144
            os.symlink('target1', 'symlink')
146
 
            self.branch.working_tree().add(['symlink'], ['linkid'])
147
 
        self.wt.commit('message_1', rev_id = '1')
 
145
            self.branch.add(['symlink'], ['linkid'])
 
146
        self.branch.commit('message_1', rev_id = '1')
148
147
        print >> open('file', 'wb'), 'bar'
149
148
        if has_symlinks():
150
149
            os.unlink('symlink')
153
152
        self.inv_1 = self.branch.get_inventory('1')
154
153
        self.file_1 = self.inv_1['fileid']
155
154
        self.tree_2 = self.branch.working_tree()
156
 
        self.inv_2 = self.tree_2.read_working_inventory()
 
155
        self.inv_2 = self.branch.inventory
157
156
        self.file_2 = self.inv_2['fileid']
158
157
        if has_symlinks():
159
158
            self.link_1 = self.inv_1['linkid']
165
164
                          "old_label", self.tree_1,
166
165
                          "/dev/null", None, None,
167
166
                          output)
168
 
        self.assertEqual(output.getvalue(), "--- old_label\t\n"
169
 
                                            "+++ /dev/null\t\n"
 
167
        self.assertEqual(output.getvalue(), "--- old_label\n"
 
168
                                            "+++ /dev/null\n"
170
169
                                            "@@ -1,1 +0,0 @@\n"
171
170
                                            "-foo\n"
172
171
                                            "\n")
177
176
                          "new_label", self.tree_1,
178
177
                          "/dev/null", None, None,
179
178
                          output, reverse=True)
180
 
        self.assertEqual(output.getvalue(), "--- /dev/null\t\n"
181
 
                                            "+++ new_label\t\n"
 
179
        self.assertEqual(output.getvalue(), "--- /dev/null\n"
 
180
                                            "+++ new_label\n"
182
181
                                            "@@ -0,0 +1,1 @@\n"
183
182
                                            "+foo\n"
184
183
                                            "\n")
189
188
                          "/dev/null", self.tree_1, 
190
189
                          "new_label", self.file_2, self.tree_2,
191
190
                          output)
192
 
        self.assertEqual(output.getvalue(), "--- /dev/null\t\n"
193
 
                                            "+++ new_label\t\n"
 
191
        self.assertEqual(output.getvalue(), "--- /dev/null\n"
 
192
                                            "+++ new_label\n"
194
193
                                            "@@ -1,1 +1,1 @@\n"
195
194
                                            "-foo\n"
196
195
                                            "+bar\n"
240
239
        # to change, and then test merge patterns
241
240
        # with fake parent entries.
242
241
        super(TestSnapshot, self).setUp()
243
 
        self.branch = Branch.initialize(u'.')
244
 
        self.build_tree(['subdir/', 'subdir/file'], line_endings='binary')
245
 
        self.branch.working_tree().add(['subdir', 'subdir/file'],
246
 
                                       ['dirid', 'fileid'])
 
242
        self.branch = Branch.initialize('.')
 
243
        self.build_tree(['subdir/', 'subdir/file'])
 
244
        self.branch.add(['subdir', 'subdir/file'], ['dirid', 'fileid'])
247
245
        if has_symlinks():
248
246
            pass
249
 
        self.wt = self.branch.working_tree()
250
 
        self.wt.commit('message_1', rev_id = '1')
 
247
        self.branch.commit('message_1', rev_id = '1')
251
248
        self.tree_1 = self.branch.revision_tree('1')
252
249
        self.inv_1 = self.branch.get_inventory('1')
253
250
        self.file_1 = self.inv_1['fileid']
327
324
        #   a descendent of the other. (B, D)
328
325
        super(TestPreviousHeads, self).setUp()
329
326
        self.build_tree(['file'])
330
 
        self.branch = Branch.initialize(u'.')
331
 
        self.wt = self.branch.working_tree()
332
 
        self.wt.commit('new branch', allow_pointless=True, rev_id='A')
 
327
        self.branch = Branch.initialize('.')
 
328
        self.branch.commit('new branch', allow_pointless=True, rev_id='A')
333
329
        self.inv_A = self.branch.get_inventory('A')
334
 
        self.branch.working_tree().add(['file'], ['fileid'])
335
 
        self.wt.commit('add file', rev_id='B')
 
330
        self.branch.add(['file'], ['fileid'])
 
331
        self.branch.commit('add file', rev_id='B')
336
332
        self.inv_B = self.branch.get_inventory('B')
337
333
        self.branch.put_controlfile('revision-history', 'A\n')
338
334
        self.assertEqual(self.branch.revision_history(), ['A'])
339
 
        self.wt.commit('another add of file', rev_id='C')
 
335
        self.branch.commit('another add of file', rev_id='C')
340
336
        self.inv_C = self.branch.get_inventory('C')
341
 
        self.wt.add_pending_merge('B')
342
 
        self.wt.commit('merge in B', rev_id='D')
 
337
        self.branch.add_pending_merge('B')
 
338
        self.branch.commit('merge in B', rev_id='D')
343
339
        self.inv_D = self.branch.get_inventory('D')
344
 
        self.file_active = self.wt.inventory['fileid']
 
340
        self.file_active = self.branch.working_tree().inventory['fileid']
345
341
        self.weave = self.branch.weave_store.get_weave('fileid',
346
342
            self.branch.get_transaction())
347
343