Commit a8d640fc authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: Migrate Products.ERP5Type.DiffUtils from filesystem.

parent c45773cd
......@@ -214,7 +214,7 @@ class Git(WorkingCopy):
for stat in out.next().splitlines():
stat, path = stat.split()[4:]
stat_dict[path] = stat
# Emulate svn output for compatibility with Products.ERP5Type.DiffUtils
# Emulate svn output for compatibility with erp5.component.module.DiffUtils
template = 'Index: %%s\n%s%%s\n' % ('=' * 67)
for diff in out:
path = diff[:diff.index(' ')]
......
from Products.ERP5Type.DiffUtils import DiffFile
from erp5.component.module.DiffUtils import DiffFile
from Products.PythonScripts.standard import html_quote
def sortDiffObjectList(diff_object_list):
......
......@@ -3,7 +3,7 @@ template_tool = context.getPortalObject().portal_templates
if template_tool.getDiffFilterScriptList():
DiffFile = template_tool.getFilteredDiff
else:
from Products.ERP5Type.DiffUtils import DiffFile
from erp5.component.module.DiffUtils import DiffFile
print '<div style="color: black">'
......
......@@ -4,7 +4,7 @@
# TODO: handle Svn SSL/login exceptions, preferably reusing vcs_dialog(_error)
# TODO: Git support
from Products.ERP5Type.DiffUtils import DiffFile
from erp5.component.module.DiffUtils import DiffFile
request = context.REQUEST
try:
......
......@@ -27,7 +27,7 @@
import base64
from lxml import etree
from difflib import unified_diff
from Products.ERP5Type.DiffUtils import DiffFile
from erp5.component.module.DiffUtils import DiffFile
def diffXML(xml_plugin="", xml_erp5="", gid="", html=True):
if isinstance(xml_erp5, unicode):
......
......@@ -28,7 +28,7 @@
from lxml import etree
from erp5.component.module.XMLSyncUtils import getConduitByName
from difflib import unified_diff
from Products.ERP5Type.DiffUtils import DiffFile
from erp5.component.module.DiffUtils import DiffFile
def callAddNodeOnConduit(self, conduit_id, uid):
......
......@@ -31,7 +31,6 @@ import fnmatch, gc, glob, imp, os, re, shutil, sys, time, tarfile
from collections import defaultdict
from Shared.DC.ZRDB import Aqueduct
from Shared.DC.ZRDB.Connection import Connection as RDBConnection
from Products.ERP5Type.DiffUtils import DiffFile
from Products.ERP5Type.Globals import Persistent, PersistentMapping
from Acquisition import Implicit, aq_base, aq_inner, aq_parent
from AccessControl import ClassSecurityInfo, Unauthorized, getSecurityManager
......@@ -6024,6 +6023,7 @@ Business Template is a set of definitions, such as skins, portal types and categ
This is compatible with ERP5VCS look and feel but
it is preferred in future we use more difflib python library.
"""
from erp5.component.module.DiffUtils import DiffFile
return DiffFile(self.diffObject(REQUEST, **kw)).toHTML()
security.declareProtected(Permissions.ManagePortal, 'diffObject')
......
......@@ -39,7 +39,6 @@ from AccessControl import ClassSecurityInfo
from AccessControl.SecurityInfo import ModuleSecurityInfo
from Products.CMFActivity.ActiveResult import ActiveResult
from Products.ERP5Type.Globals import InitializeClass, DTMLFile, PersistentMapping
from Products.ERP5Type.DiffUtils import DiffFile
from Products.ERP5Type.Tool.BaseTool import BaseTool
from Products.ERP5Type.Cache import transactional_cached
from Products.ERP5Type import Permissions
......@@ -543,6 +542,7 @@ class TemplateTool (BaseTool):
"""
Filter the diff using python scripts
"""
from erp5.component.module.DiffUtils import DiffFile
diff_file_object = DiffFile(diff)
diff_block_list = diff_file_object.getModifiedBlockList()
if diff_block_list:
......@@ -563,6 +563,7 @@ class TemplateTool (BaseTool):
This is compatible with ERP5VCS look and feel but
it is preferred in future we use more difflib python library.
"""
from erp5.component.module.DiffUtils import DiffFile
return DiffFile(self.diffObject(REQUEST, **kw)).toHTML()
security.declareProtected(Permissions.ManagePortal, 'diffObject')
......
......@@ -81,7 +81,7 @@ class DiffFile(object):
# Splitting the body from the header
self.body = os.linesep.join(raw_diff.strip().splitlines()[3:])
if not self.body.startswith('@@'):
self.body = os.linesep.join(raw_diff.strip().splitlines()[4:])
self.body = os.linesep.join(raw_diff.strip().splitlines()[4:])
# Now splitting modifications
first = True
tmp = []
......@@ -192,9 +192,9 @@ class CodeBlock:
self.body = os.linesep.join(raw_diff.splitlines()[1:])
self.header = raw_diff.splitlines()[0]
# Getting modifications lines
tmp = re.search('^@@ -\d+', self.header)
tmp = re.search(r'^@@ -\d+', self.header)
self.old_line = tmp.string[tmp.start():tmp.end()][4:]
tmp = re.search('\+\d+', self.header)
tmp = re.search(r'\+\d+', self.header)
self.new_line = tmp.string[tmp.start():tmp.end()][1:]
# Splitting modifications in SubCodeBlocks
in_modif = False
......@@ -340,3 +340,6 @@ class SubCodeBlock:
if line.startswith('+'):
return (' ' + line[1:], self.color)
return (line, self.color)
from AccessControl.SecurityInfo import ModuleSecurityInfo
ModuleSecurityInfo(__name__).declarePublic('DiffFile')
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Module Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>DiffUtils</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5Type.DiffUtils</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>module.erp5.DiffUtils</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Module Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
module.erp5.DateUtils
module.erp5.DiffUtils
module.erp5.ExpandPolicy
module.erp5.GeneratedAmountList
module.erp5.MovementCollectionDiff
......
......@@ -183,7 +183,6 @@ allow_module('Products.ERP5Type.Log')
allow_module('Products.ERP5Type.ImmediateReindexContextManager')
ModuleSecurityInfo('Products.ERP5Type.JSON').declarePublic('dumps', 'loads')
ModuleSecurityInfo('Products.ERP5Type.Constraint').declarePublic('PropertyTypeValidity')
ModuleSecurityInfo('Products.ERP5Type.DiffUtils').declarePublic('DiffFile')
ModuleSecurityInfo('pprint').declarePublic('pformat', 'pprint')
ModuleSecurityInfo('Products.ERP5Type.XMLUtils').declarePublic('parseStream')
......
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