[Erp5-report] r44256 jm - in /erp5/trunk/products/ERP5VCS: Git.py Subversion.py WorkingCopy.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Mar 14 18:20:08 CET 2011
Author: jm
Date: Mon Mar 14 18:20:08 2011
New Revision: 44256
URL: http://svn.erp5.org?rev=44256&view=rev
Log:
Fix ClientError/GitError when exporting a new Business Template
Modified:
erp5/trunk/products/ERP5VCS/Git.py
erp5/trunk/products/ERP5VCS/Subversion.py
erp5/trunk/products/ERP5VCS/WorkingCopy.py
Modified: erp5/trunk/products/ERP5VCS/Git.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5VCS/Git.py?rev=44256&r1=44255&r2=44256&view=diff
==============================================================================
--- erp5/trunk/products/ERP5VCS/Git.py [utf8] (original)
+++ erp5/trunk/products/ERP5VCS/Git.py [utf8] Mon Mar 14 18:20:08 2011
@@ -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()
Modified: erp5/trunk/products/ERP5VCS/Subversion.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5VCS/Subversion.py?rev=44256&r1=44255&r2=44256&view=diff
==============================================================================
--- erp5/trunk/products/ERP5VCS/Subversion.py [utf8] (original)
+++ erp5/trunk/products/ERP5VCS/Subversion.py [utf8] Mon Mar 14 18:20:08 2011
@@ -37,7 +37,7 @@ from Products.ERP5Type.Message import tr
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):
Modified: erp5/trunk/products/ERP5VCS/WorkingCopy.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5VCS/WorkingCopy.py?rev=44256&r1=44255&r2=44256&view=diff
==============================================================================
--- erp5/trunk/products/ERP5VCS/WorkingCopy.py [utf8] (original)
+++ erp5/trunk/products/ERP5VCS/WorkingCopy.py [utf8] Mon Mar 14 18:20:08 2011
@@ -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))
More information about the Erp5-report
mailing list