Commit 9cae8b08 authored by Julien Muchembled's avatar Julien Muchembled

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
parent e47d8303
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <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 return False\n
new_line = new_line_list[0]\n new_line = new_line_list[0]\n
\n \n
......
...@@ -50,11 +50,7 @@ ...@@ -50,11 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>from Products.ERP5Type.Log import log\n <value> <string>if len(old_line_list) == 1 and len(new_line_list) == 1:\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
if new_line_list[0] == old_line_list[0].replace("string encoding","unicode encoding") and \\\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 old_line_list[0] == \'\074value\076 \074string encoding="cdata"\076\074![CDATA[\':\n
return True\n return True\n
...@@ -62,7 +58,14 @@ if len(old_line_list) == 1 and len(new_line_list) == 1:\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 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 old_line_list[0] == "]]\076\074/string\076 \074/value\076":\n
return True\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 return False\n
</string> </value> </string> </value>
</item> </item>
...@@ -86,13 +89,19 @@ return False\n ...@@ -86,13 +89,19 @@ return False\n
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <string>This script filter this kind of xml changes :\n <value> <string>This script filter the following xml changes :\n
@@\n
- \074value\076 \074string encoding="cdata"\076\074![CDATA[\n - \074value\076 \074string encoding="cdata"\076\074![CDATA[\n
+ \074value\076 \074unicode encoding="cdata"\076\074![CDATA[\n + \074value\076 \074unicode encoding="cdata"\076\074![CDATA[\n
\n @@\n
AND also\n -]]\076\074/string\076 \074/value\076\n
- ]]\076\074/string\076 \074/value\076\n +]]\076\074/unicode\076 \074/value\076\n
+ ]]\076\074/unicode\076 \074/value\076</string> </value> @@\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>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -120,11 +129,9 @@ AND also\n ...@@ -120,11 +129,9 @@ AND also\n
<tuple> <tuple>
<string>old_line_list</string> <string>old_line_list</string>
<string>new_line_list</string> <string>new_line_list</string>
<string>Products.ERP5Type.Log</string> <string>len</string>
<string>log</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>len</string>
<string>True</string> <string>True</string>
<string>False</string> <string>False</string>
</tuple> </tuple>
......
1779 1780
\ No newline at end of file \ No newline at end of file
...@@ -158,11 +158,13 @@ class DiffFile: ...@@ -158,11 +158,13 @@ class DiffFile:
return [] return []
block_list = [] block_list = []
for child in self.children: for child in self.children:
old_line_list = [x[0].strip() for x in child.getOldCodeList() old_line_list = [line.strip() for line, color in child.getOldCodeList()
if x[0] is not None and x[1] == MODIFIED_DIFF_COLOR] if line is not None and color in (MODIFIED_DIFF_COLOR,
new_line_list = [x[0].strip() for x in child.getNewCodeList() DELETED_DIFF_COLOR)]
if x[0] is not None and x[1] == MODIFIED_DIFF_COLOR] new_line_list = [line.strip() for line, color in child.getNewCodeList()
if old_line_list and new_line_list: 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))) block_list.append((child,(old_line_list, new_line_list)))
return block_list return block_list
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment