From 201a03c86e9c9ff9a9a69eabb385a8fbdb438c8d Mon Sep 17 00:00:00 2001 From: Christophe Dumez <christophe@nexedi.com> Date: Tue, 25 Jul 2006 13:54:06 +0000 Subject: [PATCH] - Added a function that updates the business template without reverting changes git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@8744 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Subversion/Tool/SubversionTool.py | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/product/ERP5Subversion/Tool/SubversionTool.py b/product/ERP5Subversion/Tool/SubversionTool.py index 6c4f056129..a4f4a4f0ab 100644 --- a/product/ERP5Subversion/Tool/SubversionTool.py +++ b/product/ERP5Subversion/Tool/SubversionTool.py @@ -134,6 +134,11 @@ class SubversionNotAWorkingCopyError(Exception): """ pass +class SubversionConflictError(Exception): + """The base exception class when there is a conflict + """ + pass + class SubversionBusinessTemplateNotInstalled(Exception): """ Exception called when the business template is not installed """ @@ -732,7 +737,9 @@ class SubversionTool(BaseTool, UniqueObject, Folder): security.declareProtected('Import/Export objects', 'update') def update(self, business_template): - """Update a working copy. + """ + Update a working copy / business template, + reverting all local changes """ path = self._getWorkingPath(self.getSubversionPath(business_template)) # First remove unversioned in working copy that could conflict @@ -747,6 +754,29 @@ class SubversionTool(BaseTool, UniqueObject, Folder): client.update(path) # Import in zodb return self.importBT(business_template) + + security.declareProtected('Import/Export objects', 'updateKeep') + def updateKeep(self, business_template): + """ + Update a working copy / business template, + keeping all local changes + """ + path = self._getWorkingPath(self.getSubversionPath(business_template)) + client = self._getClient() + # Revert revision file so that it does not conflict + revision_path = os.path.join(path, 'bt', 'revision') + if os.path.exists(revision_path): + self.revert(path=revision_path, recurse=False) + # remove unversioned files in working copy that could be annoying + self.removeAllInList(x['uid'] for x in self.unversionedFiles(path)) + # Update from SVN + client.update(path) + # Check if some files are conflicted to raise an exception + conflicted_list = self.conflictedFiles(self.getSubversionPath(business_template)) + if len(conflicted_list) != 0: + raise SubversionConflictError, 'The following files conflicts (%s), please resolve manually.' % repr(conflicted_list) + # Import in zodb + return self.importBT(business_template) security.declareProtected('Import/Export objects', 'switch') def switch(self, business_template, url): -- 2.30.9