Commit d3ae7918 authored by Julien Muchembled's avatar Julien Muchembled

Fix ClientError/GitError when exporting a new Business Template

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@44256 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c8397666
......@@ -33,7 +33,7 @@ from DateTime import DateTime
from Products.ERP5Type.Message import translateString
from ZTUtils import make_query
from Products.ERP5VCS.WorkingCopy import \
WorkingCopy, NotAWorkingCopyError, Dir, File, selfcached
WorkingCopy, NotAWorkingCopyError, NotVersionedError, Dir, File, selfcached
class GitError(EnvironmentError):
def __init__(self, err, out, returncode):
......@@ -223,8 +223,14 @@ class Git(WorkingCopy):
return self.aq_parent.download(self.working_copy)
def showOld(self, path):
return self.git('show', 'HEAD:' + self.prefix + path,
strip=False, cwd=self.toplevel)
try:
return self.git('show', 'HEAD:' + self.prefix + path,
strip=False, cwd=self.toplevel)
except GitError, e:
err = e.args[0]
if ' does not exist in ' in err or ' exists on disk, but not in ' in err:
raise NotVersionedError(path)
raise
def getAuthor(self):
portal = self.getPortalObject()
......
......@@ -37,7 +37,7 @@ from Products.ERP5Type.Message import translateString
from Products.ERP5.Document.BusinessTemplate import BusinessTemplateFolder
from Products.ERP5VCS.WorkingCopy import \
WorkingCopy, Dir, File, chdir_working_copy, selfcached, \
NotAWorkingCopyError, VcsConflictError
NotAWorkingCopyError, NotVersionedError, VcsConflictError
from Products.ERP5VCS.SubversionClient import \
newSubversionClient, SubversionLoginError, SubversionSSLTrustError
......@@ -139,9 +139,14 @@ class Subversion(WorkingCopy):
return self.aq_parent.download('.')
def showOld(self, path):
from pysvn import Revision, opt_revision_kind
return self._getClient().cat(os.path.join(self.working_copy, path),
Revision(opt_revision_kind.base))
from pysvn import ClientError, Revision, opt_revision_kind, svn_err
try:
return self._getClient().cat(os.path.join(self.working_copy, path),
Revision(opt_revision_kind.base))
except ClientError, e:
if e.args[1][-1][1] in (errno.ENOENT, svn_err.entry_not_found):
raise NotVersionedError(path)
raise
@selfcached
def info(self):
......
......@@ -72,6 +72,9 @@ def selfcached(func):
class NotAWorkingCopyError(Exception): pass
ModuleSecurityInfo(__name__).declarePublic('NotAWorkingCopyError')
class NotVersionedError(Exception): pass
ModuleSecurityInfo(__name__).declarePublic('NotVersionedError')
class BusinessTemplateNotInstalled(Exception): pass
ModuleSecurityInfo(__name__).declarePublic('BusinessTemplateNotInstalled')
......@@ -200,7 +203,10 @@ class WorkingCopy(Implicit):
def newRevision(self):
path = os.path.join('bt', 'revision')
revision = int(self.showOld(path)) + 1
try:
revision = int(self.showOld(path)) + 1
except NotVersionedError:
return 1
file = open(os.path.join(self.working_copy, path), 'w')
try:
file.write(str(revision))
......
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