Merge 0.4.
[jelmer/subvertpy.git] / errors.py
index 29d03e29abc53a0ab45e9c81b094e6d84282028b..83c4ea47b3b88ba6ce0a0374d3e36ff3f40a0fd9 100644 (file)
--- a/errors.py
+++ b/errors.py
@@ -2,7 +2,7 @@
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
+# the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
 
 # This program is distributed in the hope that it will be useful,
 from bzrlib.errors import (BzrError, ConnectionError, ConnectionReset, 
                            LockError, NotBranchError, PermissionDenied, 
                            DependencyNotPresent, NoRepositoryPresent,
-                           TransportError, UnexpectedEndOfContainerError)
+                           TransportError, UnexpectedEndOfContainerError,
+                           RedirectRequested)
 
 import urllib
-import svn.core
+from bzrlib.plugins.svn import core
+
+
+class InvalidExternalsDescription(BzrError):
+    _fmt = """Unable to parse externals description."""
+
+
+ERR_UNKNOWN_HOSTNAME = 670002
+ERR_UNKNOWN_HOSTNAME = 670002
+ERR_RA_SVN_CONNECTION_CLOSED = 210002
+ERR_WC_LOCKED = 155004
+ERR_RA_NOT_AUTHORIZED = 170001
+ERR_INCOMPLETE_DATA = 200003
+ERR_RA_SVN_MALFORMED_DATA = 210004
+ERR_RA_NOT_IMPLEMENTED = 170003
+ERR_FS_NO_SUCH_REVISION = 160006
+ERR_FS_TXN_OUT_OF_DATE = 160028
+ERR_REPOS_DISABLED_FEATURE = 165006
+ERR_STREAM_MALFORMED_DATA = 140001
+ERR_RA_ILLEGAL_URL = 170000
+ERR_RA_LOCAL_REPOS_OPEN_FAILED = 180001
+ERR_BAD_URL = 125002
+ERR_RA_DAV_REQUEST_FAILED = 175002
+ERR_RA_DAV_PATH_NOT_FOUND = 175007
+ERR_FS_NOT_DIRECTORY = 160016
+ERR_FS_NOT_FOUND = 160013
+ERR_FS_ALREADY_EXISTS = 160020
+ERR_RA_SVN_REPOS_NOT_FOUND = 210005
+ERR_WC_NOT_DIRECTORY = 155007
+ERR_ENTRY_EXISTS = 150002
+ERR_WC_PATH_NOT_FOUND = 155010
+ERR_CANCELLED = 200015
+ERR_WC_UNSUPPORTED_FORMAT = 155021
+ERR_UNKNOWN_CAPABILITY = 200026
+ERR_AUTHN_NO_PROVIDER = 215001
+ERR_RA_DAV_RELOCATED = 175011
 
-# APR define, not in svn.core
-SVN_ERR_UNKNOWN_HOSTNAME = 670002
 
 class NotSvnBranchPath(NotBranchError):
     """Error raised when a path was specified that did not exist."""
     _fmt = """%(path)s is not a valid Subversion branch path. 
 See 'bzr help svn-branching-schemes' for details."""
 
-    def __init__(self, branch_path, scheme=None):
+    def __init__(self, branch_path, mapping=None):
         NotBranchError.__init__(self, urllib.quote(branch_path))
-        self.scheme = scheme
-
-
-class InvalidSvnBranchPath(NotBranchError):
-    """Error raised when a path was specified that is not a child of or itself
-    a valid branch path in the current branching scheme."""
-    _fmt = """%(path)s is not a valid Subversion branch path in the current 
-branching scheme. See 'bzr help svn-branching-schemes' for details."""
-
-    def __init__(self, path, scheme):
-        assert isinstance(path, str)
-        NotBranchError.__init__(self, urllib.quote(path))
-        self.scheme = scheme
+        self.mapping = mapping
 
 
 class NoSvnRepositoryPresent(NoRepositoryPresent):
@@ -83,19 +105,19 @@ def convert_error(err):
     """
     (msg, num) = err.args
 
-    if num == svn.core.SVN_ERR_RA_SVN_CONNECTION_CLOSED:
+    if num == ERR_RA_SVN_CONNECTION_CLOSED:
         return ConnectionReset(msg=msg)
-    elif num == svn.core.SVN_ERR_WC_LOCKED:
+    elif num == ERR_WC_LOCKED:
         return LockError(message=msg)
-    elif num == svn.core.SVN_ERR_RA_NOT_AUTHORIZED:
+    elif num == ERR_RA_NOT_AUTHORIZED:
         return PermissionDenied('.', msg)
-    elif num == svn.core.SVN_ERR_INCOMPLETE_DATA:
+    elif num == ERR_INCOMPLETE_DATA:
         return UnexpectedEndOfContainerError()
-    elif num == svn.core.SVN_ERR_RA_SVN_MALFORMED_DATA:
+    elif num == ERR_RA_SVN_MALFORMED_DATA:
         return TransportError("Malformed data", msg)
-    elif num == svn.core.SVN_ERR_RA_NOT_IMPLEMENTED:
+    elif num == ERR_RA_NOT_IMPLEMENTED:
         return NotImplementedError("Function not implemented in remote server")
-    elif num == SVN_ERR_UNKNOWN_HOSTNAME:
+    elif num == ERR_UNKNOWN_HOSTNAME:
         return ConnectionError(msg=msg)
     elif num > 0 and num < 1000:
         return OSError(num, msg)
@@ -110,7 +132,7 @@ def convert_svn_error(unbound):
     def convert(*args, **kwargs):
         try:
             return unbound(*args, **kwargs)
-        except svn.core.SubversionException, e:
+        except core.SubversionException, e:
             raise convert_error(e)
 
     convert.__doc__ = unbound.__doc__
@@ -118,11 +140,6 @@ def convert_svn_error(unbound):
     return convert
 
 
-class NoCheckoutSupport(BzrError):
-
-    _fmt = 'Subversion version too old for working tree support.'
-
-
 class LocalCommitsUnsupported(BzrError):
 
     _fmt = 'Local commits are not supported for lightweight Subversion checkouts.'
@@ -157,3 +174,16 @@ class CorruptMappingData(BzrError):
     def __init__(self, path):
         BzrError.__init__(self)
         self.path = path
+
+
+class InvalidSvnBranchPath(NotBranchError):
+    """Error raised when a path was specified that is not a child of or itself
+    a valid branch path in the current branching scheme."""
+    _fmt = """%(path)s is not a valid Subversion branch path in the current 
+repository layout. See 'bzr help svn-repository-layout' for details."""
+
+    def __init__(self, path, layout):
+        assert isinstance(path, str)
+        NotBranchError.__init__(self, urllib.quote(path))
+        self.layout = layout
+