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:
266
short_status = """A f1
272
repo = wt.branch.repository
273
d = wt.changes_from(repo.revision_tree(_mod_revision.NULL_REVISION))
274
return d, long_status, short_status
276
def test_delta_show_short_status_no_filter(self):
277
d, long_status, short_status = self._get_delta()
279
d.show(out, short_status=True)
280
self.assertEquals(short_status, out.getvalue())
282
def test_delta_show_long_status_no_filter(self):
283
d, long_status, short_status = self._get_delta()
285
d.show(out, short_status=False)
286
self.assertEquals(long_status, out.getvalue())
288
def test_delta_show_no_filter(self):
289
d, long_status, short_status = self._get_delta()
291
def not_a_filter(path):
293
d.show(out, short_status=True, path_filter=not_a_filter)
294
self.assertEquals(short_status, out.getvalue())
296
def test_delta_show_short_status_single_file_filter(self):
297
d, long_status, short_status = self._get_delta()
301
d.show(out, short_status=True, path_filter=only_f2)
302
self.assertEquals("A f2\n", out.getvalue())
304
def test_delta_show_long_status_single_file_filter(self):
305
d, long_status, short_status = self._get_delta()
309
d.show(out, short_status=False, path_filter=only_f2)
310
self.assertEquals("added:\n f2\n", out.getvalue())