215
215
builder.finish_series()
216
216
self.builder = builder
218
def test_resolve_taking_this(self):
218
def _merge_other_into_this(self):
219
219
b = self.builder.get_branch()
220
220
wt = b.bzrdir.sprout('branch').open_workingtree()
221
221
wt.merge_from_branch(b, 'other')
222
# Check that we got the right conflict
224
def assertConflict(self, wt, ctype, **kwargs):
223
225
confs = wt.conflicts()
224
226
self.assertEqual(1, len(confs))
226
self.assertIsInstance(confs[0], conflicts.ContentsConflict)
227
self.assertEqual('file-id', c.file_id)
228
self.assertEqual('file', c.path)
229
conflicts.resolve(wt, ['file'], action='take_this')
228
self.assertIsInstance(c, ctype)
229
sentinel = object() # An impossible value
230
for k, v in kwargs.iteritems():
231
self.assertEqual(v, getattr(c, k, sentinel))
233
def assertResolved(self, wt, item, action):
234
conflicts.resolve(wt, [item], action=action)
230
235
# Check that we don't have any conflicts nor unknown left
231
236
self.assertEqual(0, len(wt.conflicts()))
232
237
self.assertEqual(0, len(list(wt.unknowns())))
239
def test_resolve_taking_this(self):
240
wt = self._merge_other_into_this()
241
self.assertConflict(wt, conflicts.ContentsConflict,
242
path='file', file_id='file-id',)
243
self.assertResolved(wt, 'file', 'take_this')
245
def test_resolve_taking_other(self):
246
wt = self._merge_other_into_this()
247
self.assertConflict(wt, conflicts.ContentsConflict,
248
path='file', file_id='file-id',)
249
self.assertResolved(wt, 'file', 'take_other')
235
252
class OldTestResolveContentConflicts(TestResolveConflicts):