~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_knit.py

MergeĀ inĀ upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
            factory = KnitPlainFactory()
45
45
        else:
46
46
            factory = None
47
 
        return KnitVersionedFile('test', LocalTransport('.'), access_mode='w', factory=factory)
 
47
        return KnitVersionedFile('test', LocalTransport('.'), access_mode='w', factory=factory, create=True)
48
48
 
49
49
    def test_knit_add(self):
50
50
        """Store one text in knit and retrieve"""
58
58
        k = self.make_test_knit()
59
59
        k.add_lines('text-1', [], split_lines(TEXT_1))
60
60
        del k
61
 
        k2 = KnitVersionedFile('test', LocalTransport('.'), access_mode='r', factory=KnitPlainFactory())
 
61
        k2 = KnitVersionedFile('test', LocalTransport('.'), access_mode='r', factory=KnitPlainFactory(), create=True)
62
62
        self.assertTrue(k2.has_version('text-1'))
63
63
        self.assertEqualDiff(''.join(k2.get_lines('text-1')), TEXT_1)
64
64
 
86
86
    def test_incomplete(self):
87
87
        """Test if texts without a ending line-end can be inserted and
88
88
        extracted."""
89
 
        k = KnitVersionedFile('test', LocalTransport('.'), delta=False)
 
89
        k = KnitVersionedFile('test', LocalTransport('.'), delta=False, create=True)
90
90
        k.add_lines('text-1', [], ['a\n',    'b'  ])
91
91
        k.add_lines('text-2', ['text-1'], ['a\rb\n', 'b\n'])
92
92
        self.assertEquals(k.get_lines('text-1'), ['a\n',    'b'  ])
117
117
    def test_add_delta(self):
118
118
        """Store in knit with parents"""
119
119
        k = KnitVersionedFile('test', LocalTransport('.'), factory=KnitPlainFactory(),
120
 
            delta=True)
 
120
            delta=True, create=True)
121
121
        self.add_stock_one_and_one_a(k)
122
122
        self.assertEqualDiff(''.join(k.get_lines('text-1a')), TEXT_1A)
123
123
 
124
124
    def test_annotate(self):
125
125
        """Annotations"""
126
126
        k = KnitVersionedFile('knit', LocalTransport('.'), factory=KnitAnnotateFactory(),
127
 
            delta=True)
 
127
            delta=True, create=True)
128
128
        self.insert_and_test_small_annotate(k)
129
129
 
130
130
    def insert_and_test_small_annotate(self, k):
139
139
    def test_annotate_fulltext(self):
140
140
        """Annotations"""
141
141
        k = KnitVersionedFile('knit', LocalTransport('.'), factory=KnitAnnotateFactory(),
142
 
            delta=False)
 
142
            delta=False, create=True)
143
143
        self.insert_and_test_small_annotate(k)
144
144
 
145
145
    def test_annotate_merge_1(self):
217
217
 
218
218
    def test_knit_join(self):
219
219
        """Store in knit with parents"""
220
 
        k1 = KnitVersionedFile('test1', LocalTransport('.'), factory=KnitPlainFactory())
 
220
        k1 = KnitVersionedFile('test1', LocalTransport('.'), factory=KnitPlainFactory(), create=True)
221
221
        k1.add_lines('text-a', [], split_lines(TEXT_1))
222
222
        k1.add_lines('text-b', ['text-a'], split_lines(TEXT_1))
223
223
 
226
226
 
227
227
        k1.add_lines('text-m', ['text-b', 'text-d'], split_lines(TEXT_1))
228
228
 
229
 
        k2 = KnitVersionedFile('test2', LocalTransport('.'), factory=KnitPlainFactory())
 
229
        k2 = KnitVersionedFile('test2', LocalTransport('.'), factory=KnitPlainFactory(), create=True)
230
230
        count = k2.join(k1, version_ids=['text-m'])
231
231
        self.assertEquals(count, 5)
232
232
        self.assertTrue(k2.has_version('text-a'))
234
234
 
235
235
    def test_reannotate(self):
236
236
        k1 = KnitVersionedFile('knit1', LocalTransport('.'),
237
 
                               factory=KnitAnnotateFactory())
 
237
                               factory=KnitAnnotateFactory(), create=True)
238
238
        # 0
239
239
        k1.add_lines('text-a', [], ['a\n', 'b\n'])
240
240
        # 1
241
241
        k1.add_lines('text-b', ['text-a'], ['a\n', 'c\n'])
242
242
 
243
243
        k2 = KnitVersionedFile('test2', LocalTransport('.'),
244
 
                               factory=KnitAnnotateFactory())
 
244
                               factory=KnitAnnotateFactory(), create=True)
245
245
        k2.join(k1, version_ids=['text-b'])
246
246
 
247
247
        # 2