From 9cae8b0836b54cee8b437460bdfd0ff42726bd4e Mon Sep 17 00:00:00 2001 From: Julien Muchembled <jm@nexedi.com> Date: Mon, 8 Nov 2010 17:19:08 +0000 Subject: [PATCH] Make TemplateTool_filterTemplateUnicodeDiff filter the added 'output_encoding' property - DiffUtils is changed so that filters are also called on deleted/added hunks. - Fix TemplateTool_filterPortalTypeClassDiff not to fail on deleted/added hunks. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@40067 20353a03-c40f-0410-a6d1-a30d3c3de9de --- ...TemplateTool_filterPortalTypeClassDiff.xml | 2 +- ...TemplateTool_filterTemplateUnicodeDiff.xml | 39 +++++++++++-------- product/ERP5/bootstrap/erp5_core/bt/revision | 2 +- product/ERP5Type/DiffUtils.py | 12 +++--- 4 files changed, 32 insertions(+), 23 deletions(-) diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/TemplateTool_filterPortalTypeClassDiff.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/TemplateTool_filterPortalTypeClassDiff.xml index 383e61296a..ca72ddeca4 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/TemplateTool_filterPortalTypeClassDiff.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/TemplateTool_filterPortalTypeClassDiff.xml @@ -52,7 +52,7 @@ <key> <string>_body</string> </key> <value> <string encoding="cdata"><![CDATA[ -if len(old_line_list) !=1 and len(new_line_list) != 1:\n +if len(old_line_list) !=1 or len(new_line_list) != 1:\n return False\n new_line = new_line_list[0]\n \n diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/TemplateTool_filterTemplateUnicodeDiff.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/TemplateTool_filterTemplateUnicodeDiff.xml index b4373d9fe2..9c09c3b027 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/TemplateTool_filterTemplateUnicodeDiff.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/TemplateTool_filterTemplateUnicodeDiff.xml @@ -50,11 +50,7 @@ </item> <item> <key> <string>_body</string> </key> - <value> <string>from Products.ERP5Type.Log import log\n -log(\'old_line_list\', old_line_list)\n -log(\'new_line_list\', new_line_list)\n -log(\'replace\', new_line_list[0] == old_line_list[0].replace("string encoding","unicode encoding"))\n -if len(old_line_list) == 1 and len(new_line_list) == 1:\n + <value> <string>if len(old_line_list) == 1 and len(new_line_list) == 1:\n if new_line_list[0] == old_line_list[0].replace("string encoding","unicode encoding") and \\\n old_line_list[0] == \'\074value\076 \074string encoding="cdata"\076\074![CDATA[\':\n return True\n @@ -62,7 +58,14 @@ if len(old_line_list) == 1 and len(new_line_list) == 1:\n if new_line_list[0] == old_line_list[0].replace("string","unicode") and \\\n old_line_list[0] == "]]\076\074/string\076 \074/value\076":\n return True\n -log("return False")\n +\n +elif not old_line_list and \'\\n\'.join(new_line_list) == """\\\n +\074key\076 \074string\076output_encoding\074/string\076 \074/key\076\n +\074value\076 \074string\076utf-8\074/string\076 \074/value\076\n +\074/item\076\n +\074item\076""":\n + return True\n +\n return False\n </string> </value> </item> @@ -86,13 +89,19 @@ return False\n </item> <item> <key> <string>description</string> </key> - <value> <string>This script filter this kind of xml changes :\n -- \074value\076 \074string encoding="cdata"\076\074![CDATA[\n -+ \074value\076 \074unicode encoding="cdata"\076\074![CDATA[\n -\n -AND also\n -- ]]\076\074/string\076 \074/value\076\n -+ ]]\076\074/unicode\076 \074/value\076</string> </value> + <value> <string>This script filter the following xml changes :\n +@@\n +- \074value\076 \074string encoding="cdata"\076\074![CDATA[\n ++ \074value\076 \074unicode encoding="cdata"\076\074![CDATA[\n +@@\n +-]]\076\074/string\076 \074/value\076\n ++]]\076\074/unicode\076 \074/value\076\n +@@\n ++ \074key\076 \074string\076output_encoding\074/string\076 \074/key\076\n ++ \074value\076 \074string\076utf-8\074/string\076 \074/value\076\n ++ \074/item\076\n ++ \074item\076\n +</string> </value> </item> <item> <key> <string>errors</string> </key> @@ -120,11 +129,9 @@ AND also\n <tuple> <string>old_line_list</string> <string>new_line_list</string> - <string>Products.ERP5Type.Log</string> - <string>log</string> + <string>len</string> <string>_getitem_</string> <string>_getattr_</string> - <string>len</string> <string>True</string> <string>False</string> </tuple> diff --git a/product/ERP5/bootstrap/erp5_core/bt/revision b/product/ERP5/bootstrap/erp5_core/bt/revision index 8542cbbf04..a586f53540 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/revision +++ b/product/ERP5/bootstrap/erp5_core/bt/revision @@ -1 +1 @@ -1779 \ No newline at end of file +1780 \ No newline at end of file diff --git a/product/ERP5Type/DiffUtils.py b/product/ERP5Type/DiffUtils.py index c1d69b74da..40808195c0 100644 --- a/product/ERP5Type/DiffUtils.py +++ b/product/ERP5Type/DiffUtils.py @@ -158,11 +158,13 @@ class DiffFile: return [] block_list = [] for child in self.children: - old_line_list = [x[0].strip() for x in child.getOldCodeList() - if x[0] is not None and x[1] == MODIFIED_DIFF_COLOR] - new_line_list = [x[0].strip() for x in child.getNewCodeList() - if x[0] is not None and x[1] == MODIFIED_DIFF_COLOR] - if old_line_list and new_line_list: + old_line_list = [line.strip() for line, color in child.getOldCodeList() + if line is not None and color in (MODIFIED_DIFF_COLOR, + DELETED_DIFF_COLOR)] + new_line_list = [line.strip() for line, color in child.getNewCodeList() + if line is not None and color in (MODIFIED_DIFF_COLOR, + ADDITION_DIFF_COLOR)] + if old_line_list or new_line_list: block_list.append((child,(old_line_list, new_line_list))) return block_list -- 2.30.9