~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge3.py

  • Committer: Patch Queue Manager
  • Date: 2016-02-01 19:13:13 UTC
  • mfrom: (6614.2.2 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20160201191313-wdfvmfff1djde6oq
(vila) Release 2.7.0 (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2005-2011, 2016 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
101
101
                           ['aaa', 'bbb'],
102
102
                           ['aaa', 'bbb'])
103
103
 
104
 
        self.assertEquals(m3.find_unconflicted(),
 
104
        self.assertEqual(m3.find_unconflicted(),
105
105
                          [(0, 2)])
106
106
 
107
 
        self.assertEquals(list(m3.find_sync_regions()),
 
107
        self.assertEqual(list(m3.find_sync_regions()),
108
108
                          [(0, 2,
109
109
                            0, 2,
110
110
                            0, 2),
111
111
                           (2,2, 2,2, 2,2)])
112
112
 
113
 
        self.assertEquals(list(m3.merge_regions()),
 
113
        self.assertEqual(list(m3.merge_regions()),
114
114
                          [('unchanged', 0, 2)])
115
115
 
116
 
        self.assertEquals(list(m3.merge_groups()),
 
116
        self.assertEqual(list(m3.merge_groups()),
117
117
                          [('unchanged', ['aaa', 'bbb'])])
118
118
 
119
119
    def test_front_insert(self):
123
123
 
124
124
        # todo: should use a sentinal at end as from get_matching_blocks
125
125
        # to match without zz
126
 
        self.assertEquals(list(m3.find_sync_regions()),
 
126
        self.assertEqual(list(m3.find_sync_regions()),
127
127
                          [(0,1, 2,3, 0,1),
128
128
                           (1,1, 3,3, 1,1),])
129
129
 
130
 
        self.assertEquals(list(m3.merge_regions()),
 
130
        self.assertEqual(list(m3.merge_regions()),
131
131
                          [('a', 0, 2),
132
132
                           ('unchanged', 0, 1)])
133
133
 
134
 
        self.assertEquals(list(m3.merge_groups()),
 
134
        self.assertEqual(list(m3.merge_groups()),
135
135
                          [('a', ['aaa', 'bbb']),
136
136
                           ('unchanged', ['zz'])])
137
137
 
141
141
                           [])
142
142
        # todo: should use a sentinal at end as from get_matching_blocks
143
143
        # to match without zz
144
 
        self.assertEquals(list(m3.find_sync_regions()),
 
144
        self.assertEqual(list(m3.find_sync_regions()),
145
145
                          [(0,0, 2,2, 0,0)])
146
146
 
147
 
        self.assertEquals(list(m3.merge_regions()),
 
147
        self.assertEqual(list(m3.merge_regions()),
148
148
                          [('a', 0, 2)])
149
149
 
150
 
        self.assertEquals(list(m3.merge_lines()),
 
150
        self.assertEqual(list(m3.merge_lines()),
151
151
                          ['aaa', 'bbb'])
152
152
 
153
153
    def test_no_conflicts(self):
156
156
                           ['aaa', '111', 'bbb'],
157
157
                           ['aaa', 'bbb'])
158
158
 
159
 
        self.assertEquals(m3.find_unconflicted(),
 
159
        self.assertEqual(m3.find_unconflicted(),
160
160
                          [(0, 1), (1, 2)])
161
161
 
162
 
        self.assertEquals(list(m3.find_sync_regions()),
 
162
        self.assertEqual(list(m3.find_sync_regions()),
163
163
                          [(0,1, 0,1, 0,1),
164
164
                           (1,2, 2,3, 1,2),
165
165
                           (2,2, 3,3, 2,2),])
166
166
 
167
 
        self.assertEquals(list(m3.merge_regions()),
 
167
        self.assertEqual(list(m3.merge_regions()),
168
168
                          [('unchanged', 0, 1),
169
169
                           ('a', 1, 2),
170
170
                           ('unchanged', 1, 2),])
174
174
                           ['aaa\n', 'bbb\n', '222\n'],
175
175
                           ['aaa\n', 'bbb\n'])
176
176
 
177
 
        self.assertEquals(''.join(m3.merge_lines()),
 
177
        self.assertEqual(''.join(m3.merge_lines()),
178
178
                          'aaa\nbbb\n222\n')
179
179
 
180
180
    def test_append_b(self):
182
182
                           ['aaa\n', 'bbb\n'],
183
183
                           ['aaa\n', 'bbb\n', '222\n'])
184
184
 
185
 
        self.assertEquals(''.join(m3.merge_lines()),
 
185
        self.assertEqual(''.join(m3.merge_lines()),
186
186
                          'aaa\nbbb\n222\n')
187
187
 
188
188
    def test_append_agreement(self):
190
190
                           ['aaa\n', 'bbb\n', '222\n'],
191
191
                           ['aaa\n', 'bbb\n', '222\n'])
192
192
 
193
 
        self.assertEquals(''.join(m3.merge_lines()),
 
193
        self.assertEqual(''.join(m3.merge_lines()),
194
194
                          'aaa\nbbb\n222\n')
195
195
 
196
196
    def test_append_clash(self):
203
203
                            start_marker='<<',
204
204
                            mid_marker='--',
205
205
                            end_marker='>>')
206
 
        self.assertEquals(''.join(ml),
 
206
        self.assertEqual(''.join(ml),
207
207
'''\
208
208
aaa
209
209
bbb
224
224
                            start_marker='<<',
225
225
                            mid_marker='--',
226
226
                            end_marker='>>')
227
 
        self.assertEquals(''.join(ml), 'aaa\n222\nbbb\n')
 
227
        self.assertEqual(''.join(ml), 'aaa\n222\nbbb\n')
228
228
 
229
229
 
230
230
    def test_insert_clash(self):
233
233
                           ['aaa\n', '111\n', 'bbb\n'],
234
234
                           ['aaa\n', '222\n', 'bbb\n'])
235
235
 
236
 
        self.assertEquals(m3.find_unconflicted(),
 
236
        self.assertEqual(m3.find_unconflicted(),
237
237
                          [(0, 1), (1, 2)])
238
238
 
239
 
        self.assertEquals(list(m3.find_sync_regions()),
 
239
        self.assertEqual(list(m3.find_sync_regions()),
240
240
                          [(0,1, 0,1, 0,1),
241
241
                           (1,2, 2,3, 2,3),
242
242
                           (2,2, 3,3, 3,3),])
243
243
 
244
 
        self.assertEquals(list(m3.merge_regions()),
 
244
        self.assertEqual(list(m3.merge_regions()),
245
245
                          [('unchanged', 0,1),
246
246
                           ('conflict', 1,1, 1,2, 1,2),
247
247
                           ('unchanged', 1,2)])
248
248
 
249
 
        self.assertEquals(list(m3.merge_groups()),
 
249
        self.assertEqual(list(m3.merge_groups()),
250
250
                          [('unchanged', ['aaa\n']),
251
251
                           ('conflict', [], ['111\n'], ['222\n']),
252
252
                           ('unchanged', ['bbb\n']),
257
257
                            start_marker='<<',
258
258
                            mid_marker='--',
259
259
                            end_marker='>>')
260
 
        self.assertEquals(''.join(ml),
 
260
        self.assertEqual(''.join(ml),
261
261
'''aaa
262
262
<< a
263
263
111
273
273
                           ['aaa', '111', 'bbb'],
274
274
                           ['aaa', '222', 'bbb'])
275
275
 
276
 
        self.assertEquals(m3.find_unconflicted(),
 
276
        self.assertEqual(m3.find_unconflicted(),
277
277
                          [(0, 1), (2, 3)])
278
278
 
279
 
        self.assertEquals(list(m3.find_sync_regions()),
 
279
        self.assertEqual(list(m3.find_sync_regions()),
280
280
                          [(0,1, 0,1, 0,1),
281
281
                           (2,3, 2,3, 2,3),
282
282
                           (3,3, 3,3, 3,3),])
287
287
                           ['aaa', '111', '111', '111', 'bbb'],
288
288
                           ['aaa', '222', '222', '222', '222', 'bbb'])
289
289
 
290
 
        self.assertEquals(m3.find_unconflicted(),
 
290
        self.assertEqual(m3.find_unconflicted(),
291
291
                          [(0, 1), (3, 4)])
292
292
 
293
293
 
294
 
        self.assertEquals(list(m3.find_sync_regions()),
 
294
        self.assertEqual(list(m3.find_sync_regions()),
295
295
                          [(0,1, 0,1, 0,1),
296
296
                           (3,4, 4,5, 5,6),
297
297
                           (4,4, 5,5, 6,6),])
302
302
        ml = list(m3.merge_lines('LAO', 'TAO'))
303
303
        self.log('merge result:')
304
304
        self.log(''.join(ml))
305
 
        self.assertEquals(ml, MERGED_RESULT)
 
305
        self.assertEqual(ml, MERGED_RESULT)
306
306
 
307
307
    def test_minimal_conflicts_common(self):
308
308
        """Reprocessing"""