From 6cafee54913e4ef6dd7a2ad94074d4ec1ee0fbad Mon Sep 17 00:00:00 2001 From: Christophe Dumez <christophe@nexedi.com> Date: Wed, 12 Apr 2006 13:17:28 +0000 Subject: [PATCH] - Look for the file (svn temp dir) if this file has been deleted with 'svn del' cmd to display content git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6555 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Subversion/Tool/SubversionTool.py | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/product/ERP5Subversion/Tool/SubversionTool.py b/product/ERP5Subversion/Tool/SubversionTool.py index 55b0648e94..4c23dac548 100644 --- a/product/ERP5Subversion/Tool/SubversionTool.py +++ b/product/ERP5Subversion/Tool/SubversionTool.py @@ -456,22 +456,31 @@ class SubversionTool(UniqueObject, Folder): # Display a file content in HTML def fileHTML(self, bt, file_path): -# file = open(file_path, 'r') -# text = file.read() -# file.close() -# # Escaping -# text = text.replace("&", "&") -# text = text.replace(">", ">") -# text = text.replace("<", "<") -# # Adding HTML stuff -# text = text.replace('\n', '<br>') -# text = text.replace('\t', ' ') -# text = text.replace(' ', ' ') - head = "<b>"+file_path+"</b> <a href='"+self.editPath(bt, file_path)+"'><img src='imgs/edit.png' border='0'></a><hr>" - text = commands.getoutput('enscript -B --color --line-numbers --highlight=html --language=html -o - %s'%file_path) - text = head + '\n'.join(text.split('\n')[10:-4]) - return text - + if os.path.exists(file_path): + if os.path.isdir(file_path): + text = "<b>"+file_path+"</b><hr>" + text = file_path +" is a folder!" + else: + head = "<b>"+file_path+"</b> <a href='"+self.editPath(bt, file_path)+"'><img src='imgs/edit.png' border='0'></a><hr>" + text = commands.getoutput('enscript -B --color --line-numbers --highlight=html --language=html -o - %s'%file_path) + text = head + '\n'.join(text.split('\n')[10:-4]) + return text + else: + # see if tmp file is here (svn deleted file) + if file_path[-1]=='/': + file_path=file_path[:-1] + filename = file_path.split('/')[-1] + tmp_path = '/'.join(file_path.split('/')[:-1]) + tmp_path = tmp_path+'/.svn/text-base/'+filename+'.svn-base' + if os.path.exists(tmp_path): + head = "<b>"+tmp_path+"</b> (svn temporary file)<hr>" + text = commands.getoutput('enscript -B --color --line-numbers --highlight=html --language=html -o - %s'%tmp_path) + text = head + '\n'.join(text.split('\n')[10:-4]) + else : # does not exist + text = "<b>"+file_path+"</b><hr>" + text = file_path +" does not exist!" + return text + security.declareProtected(Permissions.ManagePortal, 'acceptSSLServer') def acceptSSLServer(self, trust_dict, permanent=False): """Accept a SSL server. -- 2.30.9