/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 bzrlib/tests/interversionedfile_implementations/test_join.py

  • Committer: Robert Collins
  • Date: 2007-09-19 05:14:14 UTC
  • mto: (2835.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 2836.
  • Revision ID: robertc@robertcollins.net-20070919051414-2tgjqteg7k3ps4h0
* ``pull``, ``merge`` and ``push`` will no longer silently correct some
  repository index errors that occured as a result of the Weave disk format.
  Instead the ``reconcile`` command needs to be run to correct those
  problems if they exist (and it has been able to fix most such problems
  since bzr 0.8). Some new problems have been identified during this release
  and you should run ``bzr check`` once on every repository to see if you
  need to reconcile. If you cannot ``pull`` or ``merge`` from a remote
  repository due to mismatched parent errors - a symptom of index errors -
  you should simply take a full copy of that remote repository to a clean
  directory outside any local repositories, then run reconcile on it, and
  finally pull from it locally. (And naturally email the repositories owner
  to ask them to upgrade and run reconcile).
  (Robert Collins)

* ``VersionedFile.fix_parents`` has been removed as a harmful API.
  ``VersionedFile.join`` will no longer accept different parents on either
  side of a join - it will either ignore them, or error, depending on the
  implementation. See notes when upgrading for more information.
  (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
        self.assertRaises(errors.RevisionNotPresent,
55
55
            f2.join, f1, version_ids=['r3'])
56
56
 
57
 
        #f3 = self.get_file('1')
58
 
        #f3.add_lines('r0', ['a\n', 'b\n'], [])
59
 
        #f3.add_lines('r1', ['c\n', 'b\n'], ['r0'])
60
 
        #f4 = self.get_file('2')
61
 
        #f4.join(f3, ['r0'])
62
 
        #self.assertTrue(f4.has_version('r0'))
63
 
        #self.assertFalse(f4.has_version('r1'))
64
 
 
65
57
    def test_gets_expected_inter_worker(self):
66
58
        source = self.get_source()
67
59
        target = self.get_target()
87
79
        self.assertTrue(target.has_version('namedleft'))
88
80
        self.assertTrue(target.has_version('namedright'))
89
81
 
90
 
    def test_join_add_parents(self):
91
 
        """Join inserting new parents into existing versions
92
 
        
93
 
        The new version must have the right parent list and must identify
94
 
        lines originating in another parent.
95
 
        """
 
82
    def test_join_different_parents_existing_version(self):
 
83
        """This may either ignore or error."""
96
84
        w1 = self.get_target('w1')
97
85
        w2 = self.get_source('w2')
98
86
        w1.add_lines('v-1', [], ['line 1\n'])
99
87
        w2.add_lines('v-2', [], ['line 2\n'])
100
88
        w1.add_lines('v-3', ['v-1'], ['line 1\n'])
101
89
        w2.add_lines('v-3', ['v-2'], ['line 1\n'])
102
 
        w1.join(w2)
 
90
        try:
 
91
            w1.join(w2)
 
92
        except errors.WeaveParentMismatch:
 
93
            # Acceptable behaviour:
 
94
            return
103
95
        self.assertEqual(sorted(w1.versions()),
104
96
                         'v-1 v-2 v-3'.split())
105
97
        self.assertEqualDiff(w1.get_text('v-3'),
106
98
                'line 1\n')
107
99
        self.assertEqual(sorted(w1.get_parents('v-3')),
108
 
                ['v-1', 'v-2'])
 
100
                ['v-1'])
109
101
        ann = list(w1.annotate('v-3'))
110
102
        self.assertEqual(len(ann), 1)
111
103
        self.assertEqual(ann[0][0], 'v-1')
148
140
        t.join(s)
149
141
        self.assertEqual(['base'], t.get_parents('text'))
150
142
 
151
 
    def test_join_with_ghosts_merges_parents(self):
152
 
        """Join combined parent lists"""
153
 
        wa = self.build_weave1()
154
 
        wb = self.get_target()
155
 
        wb.add_lines('x1', [], ['line from x1\n'])
156
 
        wb.add_lines('v1', [], ['hello\n'])
157
 
        wb.add_lines('v2', ['v1', 'x1'], ['hello\n', 'world\n'])
158
 
        wa.join(wb)
159
 
        self.assertEqual(['v1','x1'], wa.get_parents('v2'))
160
 
 
161
143
    def test_join_with_ghosts(self):
162
144
        """Join that inserts parents of an existing revision.
163
145
 
164
 
        This can happen when merging from another branch who
165
 
        knows about revisions the destination does not.  In 
166
 
        this test the second weave knows of an additional parent of 
167
 
        v2.  Any revisions which are in common still have to have the 
168
 
        same text.
 
146
        This can happen when merging from another branch who knows about
 
147
        revisions the destination does not, and the destinations index is
 
148
        incorrect because it was or is using a ghost-unaware format to
 
149
        represent the index. In this test the second weave knows of an
 
150
        additional parent of v2.
 
151
        
 
152
        However v2 must not be changed because we consider indexes immutable:
 
153
        instead a check or reconcile operation locally should pickup that v2 is
 
154
        wrong and regenerate the index at a later time. So either this errors,
 
155
        or leaves v2 unaltered.
169
156
        """
170
157
        w1 = self.build_weave1()
171
158
        wb = self.get_target()
172
159
        wb.add_lines('x1', [], ['line from x1\n'])
173
160
        wb.add_lines('v1', [], ['hello\n'])
174
161
        wb.add_lines('v2', ['v1', 'x1'], ['hello\n', 'world\n'])
175
 
        w1.join(wb)
176
 
        eq = self.assertEquals
177
 
        eq(sorted(w1.versions()), ['v1', 'v2', 'v3', 'x1',])
178
 
        eq(w1.get_text('x1'), 'line from x1\n')
179
 
        eq(w1.get_lines('v2'), ['hello\n', 'world\n'])
180
 
        eq(w1.get_parents('v2'), ['v1', 'x1'])
 
162
        try:
 
163
            w1.join(wb)
 
164
        except errors.WeaveParentMismatch:
 
165
            # Acceptable behaviour:
 
166
            return
 
167
        self.assertEqual(['v1', 'v2', 'v3', 'x1',], sorted(w1.versions()))
 
168
        self.assertEqual('line from x1\n', w1.get_text('x1'))
 
169
        self.assertEqual(['hello\n', 'world\n'], w1.get_lines('v2'))
 
170
        self.assertEqual(['v1'], w1.get_parents('v2'))
181
171
 
182
172
    def test_join_with_ignore_missing_versions(self):
183
173
        # test that ignore_missing=True makes a listed but absent version id
205
195
        for version, parents in pattern:
206
196
            w.add_lines(version, parents, [])
207
197
        return w
208
 
 
209
 
    def test_join_reorder(self):
210
 
        """Reweave requiring reordering of versions.
211
 
 
212
 
        Weaves must be stored such that parents come before children.  When
213
 
        reweaving, we may add new parents to some children, but it is required
214
 
        that there must be *some* valid order that can be found, otherwise the
215
 
        ancestries are contradictory.  (For the specific case of inserting
216
 
        ghost revisions there will be no disagreement, only partial knowledge
217
 
        of the history.)
218
 
 
219
 
        Note that the weaves are only partially ordered: when there are two
220
 
        versions where neither is an ancestor of the other the order in which
221
 
        they occur is unconstrained.  When we join those versions into
222
 
        another weave, they may become more constrained and it may be
223
 
        necessary to change their order.
224
 
 
225
 
        One simple case of this is 
226
 
 
227
 
        w1: (c[], a[], b[a])
228
 
        w2: (b[], c[b], a[])
229
 
        
230
 
        We need to recognize that the final weave must show the ordering
231
 
        a[], b[a], c[b].  The version that must be first in the result is 
232
 
        not first in either of the input weaves.
233
 
        """
234
 
        w1 = self.build_target_weave('1', ('c', []), ('a', []), ('b', ['a']))
235
 
        w2 = self.build_source_weave('2', ('b', []), ('c', ['b']), ('a', []))
236
 
        w1.join(w2)
237
 
        self.assertEqual([], w1.get_parents('a'))
238
 
        self.assertEqual(['a'], w1.get_parents('b'))
239
 
        self.assertEqual(['b'], w1.get_parents('c'))
240
198
        
241
199
    def test_joining_ghosts(self):
242
200
        # some versioned file formats allow lines to be added with parent