238
239
True, False)], delta.renamed)
239
240
self.assertTrue(delta.has_changed())
240
241
self.assertTrue(delta.touches_file_id('file-id'))
244
class TestDeltaShow(tests.TestCaseWithTransport):
246
def _get_delta(self):
247
# We build the delta from a real tree to avoid depending on internal
248
# implementation details.
249
wt = self.make_branch_and_tree('branch')
250
self.build_tree_contents([('branch/f1', '1\n'),
251
('branch/f2', '2\n'),
252
('branch/f3', '3\n'),
253
('branch/f4', '4\n'),
256
wt.add(['f1', 'f2', 'f3', 'f4', 'dir'],
257
['f1-id', 'f2-id', 'f3-id', 'f4-id', 'dir-id'])
258
wt.commit('commit one', rev_id='1')
260
long_status = """added:
267
short_status = """A dir/
274
repo = wt.branch.repository
275
d = wt.changes_from(repo.revision_tree(_mod_revision.NULL_REVISION))
276
return d, long_status, short_status
278
def test_delta_show_short_status_no_filter(self):
279
d, long_status, short_status = self._get_delta()
281
d.show(out, short_status=True)
282
self.assertEquals(short_status, out.getvalue())
284
def test_delta_show_long_status_no_filter(self):
285
d, long_status, short_status = self._get_delta()
287
d.show(out, short_status=False)
288
self.assertEquals(long_status, out.getvalue())
290
def test_delta_show_no_filter(self):
291
d, long_status, short_status = self._get_delta()
293
def not_a_filter(path, file_id):
295
d.show(out, short_status=True, filter=not_a_filter)
296
self.assertEquals(short_status, out.getvalue())
298
def test_delta_show_short_status_single_file_filter(self):
299
d, long_status, short_status = self._get_delta()
301
def only_f2(path, file_id):
303
d.show(out, short_status=True, filter=only_f2)
304
self.assertEquals("A f2\n", out.getvalue())
306
def test_delta_show_long_status_single_file_filter(self):
307
d, long_status, short_status = self._get_delta()
309
def only_f2(path, file_id):
311
d.show(out, short_status=False, filter=only_f2)
312
self.assertEquals("added:\n f2\n", out.getvalue())
314
def test_delta_show_short_status_single_file_id_filter(self):
315
d, long_status, short_status = self._get_delta()
317
def only_f2_id(path, file_id):
318
return file_id == 'f2-id'
319
d.show(out, short_status=True, filter=only_f2_id)
320
self.assertEquals("A f2\n", out.getvalue())