[Erp5-report] r6470 - in /erp5/trunk/products/ERP5Subversion: ./ Tool/
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Apr 5 16:25:56 CEST 2006
Author: chris
Date: Wed Apr 5 16:25:53 2006
New Revision: 6470
URL: http://svn.erp5.org?rev=6470&view=rev
Log:
- Fixed a display bug in html diff
- improved Business template export
Modified:
erp5/trunk/products/ERP5Subversion/SubversionClient.py
erp5/trunk/products/ERP5Subversion/Tool/SubversionTool.py
Modified: erp5/trunk/products/ERP5Subversion/SubversionClient.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Subversion/SubversionClient.py?rev=6470&r1=6469&r2=6470&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Subversion/SubversionClient.py (original)
+++ erp5/trunk/products/ERP5Subversion/SubversionClient.py Wed Apr 5 16:25:53 2006
@@ -35,7 +35,7 @@
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions
from Products.PythonScripts.Utility import allow_class
-from zLOG import LOG
+from zLOG import LOG, WARNING
try:
import pysvn
@@ -122,11 +122,13 @@
class SSLServerTrustPromptCallback(Callback):
def __call__(self, trust_dict):
+ LOG('SubversionTool', WARNING, 'SSL Trust.')
trust, permanent = self.client.trustSSLServer(trust_dict)
if not trust:
- #raise SubversionSSLTrustError(trust_dict)
+ LOG('SubversionTool', WARNING, 'No Trust.')
self.client.setException(SubversionSSLTrustError(trust_dict))
return False, 0, False
+ LOG('SubversionTool', WARNING, 'Has Trust.')
# XXX SSL server certificate failure bits are not defined in pysvn.
# 0x8 means that the CA is unknown.
return True, 0x8, permanent
@@ -195,10 +197,8 @@
self.client.callback_cancel = CancelCallback(obj)
self.client.callback_get_log_message = GetLogMessageCallback(obj)
self.client.callback_get_login = GetLoginCallback(obj)
- #self.client.callback_get_login = self.callback_get_Login
self.client.callback_notify = NotifyCallback(obj)
self.client.callback_ssl_server_trust_prompt = SSLServerTrustPromptCallback(obj)
- #self.client.callback_ssl_server_trust_prompt = self.callback_ssl_server_trust_prompt
self.creation_time = time.time()
self.__dict__.update(kw)
self.exception = None
@@ -218,22 +218,9 @@
def getTimeout(self):
return self.timeout
-
-# def callback_get_Login( self, realm, username, may_save ):
-# #Retrieving saved username/password
-# username, password = self.login
-# if not username :
-# raise "Error: Couldn't retrieve saved username !"
-# if not password :
-# raise "Error: Couldn't retrieve saved password !"
-# return 1, username, password, True
def trustSSLServer(self, trust_dict):
return self.aq_parent._trustSSLServer(trust_dict)
-
-# def callback_ssl_server_trust_prompt( self, trust_data ):
-# # Always trusting
-# return True, trust_data['failures'], True
def setException(self, exc):
self.exception = exc
@@ -252,6 +239,17 @@
else:
raise error
+ def update(self, path):
+ self._getPreferences()
+ try:
+ return self.client.update(path)
+ except pysvn.ClientError, error:
+ excep = self.getException()
+ if excep:
+ raise excep
+ else:
+ raise error
+
def status(self, path, **kw):
# Since plain Python classes are not convenient in Zope, convert the objects.
return [Status(x) for x in self.client.status(path, **kw)]
@@ -267,15 +265,11 @@
def add(self, path):
self._getPreferences()
- return self.client.add(path)
+ return self.client.add(path=path, force=True)
def remove(self, path):
self._getPreferences()
- return self.client.remove(path)
-
- def update(self, path):
- self._getPreferences()
- return self.client.update(path)
+ return self.client.remove(path=path, force=True)
def newSubversionClient(container, **kw):
return SubversionClient(container, **kw).__of__(container)
@@ -286,7 +280,6 @@
allow_class(SubversionLoginError)
except ImportError:
- from zLOG import LOG, WARNING
LOG('SubversionTool', WARNING,
'could not import pysvn; until pysvn is installed properly, this tool will not work.')
def newSubversionClient(container, **kw):
Modified: erp5/trunk/products/ERP5Subversion/Tool/SubversionTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Subversion/Tool/SubversionTool.py?rev=6470&r1=6469&r2=6470&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Subversion/Tool/SubversionTool.py (original)
+++ erp5/trunk/products/ERP5Subversion/Tool/SubversionTool.py Wed Apr 5 16:25:53 2006
@@ -151,6 +151,8 @@
# Adding diff of the modification
old_code_list = child.getOldCodeList()
new_code_list = child.getNewCodeList()
+ if len(old_code_list)!=len(new_code_list):
+ raise '%s != %s for file %s'%(len(old_code_list), len(new_code_list), self.path)
i=0
for old_line_tuple in old_code_list:
new_line_tuple = new_code_list[i]
@@ -232,8 +234,10 @@
# a SubCodeBlock contain 0 or 1 modification (not more)
class SubCodeBlock:
def __init__(self, code):
- self.body=code
- self.modification=self._getModif()
+ self.body = code
+ self.modification = self._getModif()
+ self.old_code_length = self._getOldCodeLength()
+ self.new_code_length = self._getNewCodeLength()
# Choosing background color
if self.modification == 'none':
self.color = 'white'
@@ -260,14 +264,33 @@
return 'none'
return 'change'
+ def _getOldCodeLength(self):
+ nb_lines = 0
+ for line in self.body.split('\n'):
+ if not line.startswith("+"):
+ nb_lines+=1
+ return nb_lines
+
+ def _getNewCodeLength(self):
+ nb_lines = 0
+ for line in self.body.split('\n'):
+ if not line.startswith("-"):
+ nb_lines+=1
+ return nb_lines
+
# Return code before modification
def getOldCodeList(self):
if self.modification=='none':
- return [(x, 'white') for x in self.body.split('\n')]
+ old_code = [(x, 'white') for x in self.body.split('\n')]
elif self.modification=='change':
- return [self._getOldCodeList(x) for x in self.body.split('\n') if self._getOldCodeList(x)[0]]
+ old_code = [self._getOldCodeList(x) for x in self.body.split('\n') if self._getOldCodeList(x)[0]]
else: # deletion or addition
- return [self._getOldCodeList(x) for x in self.body.split('\n')]
+ old_code = [self._getOldCodeList(x) for x in self.body.split('\n')]
+ # we want old_code_list and new_code_list to have the same length
+ if(self.old_code_length < self.new_code_length):
+ filling = [(None, self.color)]*(self.new_code_length-self.old_code_length)
+ old_code.extend(filling)
+ return old_code
def _getOldCodeList(self, line):
if line.startswith('+'):
@@ -279,11 +302,16 @@
# Return code after modification
def getNewCodeList(self):
if self.modification=='none':
- return [(x, 'white') for x in self.body.split('\n')]
+ new_code = [(x, 'white') for x in self.body.split('\n')]
elif self.modification=='change':
- return [self._getNewCodeList(x) for x in self.body.split('\n') if self._getNewCodeList(x)[0]]
+ new_code = [self._getNewCodeList(x) for x in self.body.split('\n') if self._getNewCodeList(x)[0]]
else: # deletion or addition
- return [self._getNewCodeList(x) for x in self.body.split('\n')]
+ new_code = [self._getNewCodeList(x) for x in self.body.split('\n')]
+ # we want old_code_list and new_code_list to have the same length
+ if(self.new_code_length < self.old_code_length):
+ filling = [(None, self.color)]*(self.old_code_length-self.new_code_length)
+ new_code.extend(filling)
+ return new_code
def _getNewCodeList(self, line):
if line.startswith('-'):
@@ -323,8 +351,6 @@
# Filter content (ZMI))
def __init__(self):
-# working_path = self.getPortalObject().portal_preferences.getPreference('subversion_working_copy')
-# svn_username = self.getPortalObject().portal_preferences.getPreference('preferred_subversion_user_name')
return Folder.__init__(self, SubversionTool.id)
# Filter content (ZMI))
@@ -567,9 +593,10 @@
return somethingModified and root
def extractBT(self, bt, path):
+ os.system('rm -rf %s'%path)
bt.export(path=path, local=1)
svn_path = self.getPortalObject().portal_preferences.getPreference('subversion_working_copy')
- if not self.working_path :
+ if not svn_path :
raise "Error: Please set Subversion working path in preferences"
if svn_path[-1]!='/':
svn_path+='/'
@@ -582,27 +609,38 @@
self.deleteOldFiles(svn_path, path)
# add new files and copy
self.addNewFiles(svn_path, path)
+ # Clean up
+ os.system('rm -rf %s'%path)
# svn del files that have been removed in new dir
def deleteOldFiles(self, old_dir, new_dir):
# detect removed files
- output = commands.getoutput('export LC_ALL=c;diff -rq %s %s --exclude .svn | grep "Only in " | grep -v "svn-commit." | grep %s | cut -d" " -f3,4'%(new_dir, old_dir, new_dir)).replace(': ', '/')
+ output = commands.getoutput('export LC_ALL=c;diff -rq %s %s --exclude .svn | grep "Only in " | grep -v "svn-commit." | grep %s | cut -d" " -f3,4'%(new_dir, old_dir, old_dir)).replace(': ', '/')
files_list = output.split('\n')
# svn del
for file in files_list:
if file:
- self.remove(file)
+ try:
+ LOG('SubversionTool', WARNING, 'svn del %s'%file)
+ self.remove(file)
+ except:
+ pass
def addNewFiles(self, old_dir, new_dir):
# detect created files
output = commands.getoutput('export LC_ALL=c;diff -rq %s %s --exclude .svn | grep "Only in " | grep -v "svn-commit." | grep %s | cut -d" " -f3,4'%(new_dir, old_dir, old_dir)).replace(': ', '/')
files_list = output.split('\n')
# Copy files
- os.system('cp -af %s %s'%(path, svn_path))
+ LOG('SubversionTool', WARNING, 'copy %s to %s'%(new_dir, old_dir))
+ os.system('cp -af %s/* %s'%(new_dir, old_dir))
# svn add
for file in files_list:
if file:
- self.add(file.replace(new_dir, old_dir))
+ try:
+ LOG('SubversionTool', WARNING, 'svn add %s'%file.replace(new_dir, old_dir))
+ self.add(file.replace(new_dir, old_dir))
+ except:
+ pass
def treeToXML(self, item) :
output = "<?xml version='1.0' encoding='iso-8859-1'?>"+ os.linesep
More information about the Erp5-report
mailing list