Commit 201a03c8 authored by Christophe Dumez's avatar Christophe Dumez

- 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
parent ab728eae
...@@ -134,6 +134,11 @@ class SubversionNotAWorkingCopyError(Exception): ...@@ -134,6 +134,11 @@ class SubversionNotAWorkingCopyError(Exception):
""" """
pass pass
class SubversionConflictError(Exception):
"""The base exception class when there is a conflict
"""
pass
class SubversionBusinessTemplateNotInstalled(Exception): class SubversionBusinessTemplateNotInstalled(Exception):
""" Exception called when the business template is not installed """ Exception called when the business template is not installed
""" """
...@@ -732,7 +737,9 @@ class SubversionTool(BaseTool, UniqueObject, Folder): ...@@ -732,7 +737,9 @@ class SubversionTool(BaseTool, UniqueObject, Folder):
security.declareProtected('Import/Export objects', 'update') security.declareProtected('Import/Export objects', 'update')
def update(self, business_template): 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)) path = self._getWorkingPath(self.getSubversionPath(business_template))
# First remove unversioned in working copy that could conflict # First remove unversioned in working copy that could conflict
...@@ -748,6 +755,29 @@ class SubversionTool(BaseTool, UniqueObject, Folder): ...@@ -748,6 +755,29 @@ class SubversionTool(BaseTool, UniqueObject, Folder):
# Import in zodb # Import in zodb
return self.importBT(business_template) 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') security.declareProtected('Import/Export objects', 'switch')
def switch(self, business_template, url): def switch(self, business_template, url):
"""switch SVN repository for a working copy. """switch SVN repository for a working copy.
......
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