changeset 2188:aab8393cac11

update _render_data_diff_text func
author Ana Balica <ana.balica@gmail.com>
date Wed, 11 Sep 2013 18:35:59 +0300
parents 1d445aa84ecf
children 51fb18308a79
files MoinMoin/items/_tests/test_Content.py MoinMoin/items/content.py
diffstat 2 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/items/_tests/test_Content.py	Wed Sep 11 01:25:56 2013 +0300
+++ b/MoinMoin/items/_tests/test_Content.py	Wed Sep 11 18:35:59 2013 +0300
@@ -233,14 +233,15 @@
         item = Item.create(item_name)
         contenttype = u'text/plain;charset=utf-8'
         meta = {CONTENTTYPE: contenttype}
-        item._save(meta)
+        data1 = "old_data"
+        item._save(meta, data1)
         item1 = Item.create(item_name)
-        data = 'test_data'
+        data2 = 'new_data'
         comment = u'next revision'
-        item1._save(meta, data, comment=comment)
+        item1._save(meta, data2, comment=comment)
         item2 = Item.create(item_name)
         result = Text._render_data_diff_text(item1.content, item1.rev, item2.rev)
-        expected = u'- \n+ test_data'
+        expected = u'- old_data\n+ new_data'
         assert result == expected
         assert item2.content.data == ''
 
--- a/MoinMoin/items/content.py	Wed Sep 11 01:25:56 2013 +0300
+++ b/MoinMoin/items/content.py	Wed Sep 11 18:35:59 2013 +0300
@@ -898,10 +898,13 @@
         return self._render_data_diff_html(oldrev, newrev, 'diff_text.html')
 
     def _render_data_diff_text(self, oldrev, newrev):
-        from MoinMoin.util import diff_text
-        oldlines = self.data_storage_to_internal(oldrev.data.read()).split('\n')
-        newlines = self.data_storage_to_internal(newrev.data.read()).split('\n')
-        difflines = diff_text.diff(oldlines, newlines)
+        """ Render text diff of 2 revisions' contents
+
+        :param oldrev: old revision object
+        :param newrev: new revision object
+        :return: text data of a content diff
+        """
+        difflines = self._get_data_diff_text(oldrev.data, newrev.data)
         return '\n'.join(difflines)
 
     _render_data_diff_raw = _render_data_diff