changeset 224:2165461d2dd8

Exception clean-ups; use symbolic names & avoid Python 2.6 deprecations.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Thu, 19 Mar 2009 21:27:39 +0100
parents a421aca2b0f5
children 2117cb0118fe
files __init__.py fetch_command.py hg_delta_editor.py svncommand.py svnwrap/svn_swig_wrapper.py
diffstat 5 files changed, 14 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/__init__.py
+++ b/__init__.py
@@ -37,7 +37,7 @@ def svn(ui, repo, subcommand, *args, **o
     try:
         return svncommand.svncmd(ui, repo, subcommand, *args, **opts)
     except core.SubversionException, e:
-        if e.apr_err == 230001:
+        if e.apr_err == core.SVN_ERR_RA_SERF_SSL_CERT_UNTRUSTED:
             raise mutil.Abort('It appears svn does not trust the ssl cert for this site.\n'
                      'Please try running svn ls on that url first.')
         raise
@@ -60,7 +60,7 @@ def svn_fetch(ui, svn_url, hg_repo_path=
     try:
         res = fetch_command.fetch_revisions(ui, svn_url, hg_repo_path, **opts)
     except core.SubversionException, e:
-        if e.apr_err == 230001:
+        if e.apr_err == core.SVN_ERR_RA_SERF_SSL_CERT_UNTRUSTED:
             raise mutil.Abort('It appears svn does not trust the ssl cert for this site.\n'
                      'Please try running svn ls on that url first.')
         raise
--- a/fetch_command.py
+++ b/fetch_command.py
@@ -100,13 +100,11 @@ def fetch_revisions(ui, svn_url, hg_repo
                     merc_util.rename(tmpfile,
                                      hg_editor.last_revision_handled_file)
                 except core.SubversionException, e: #pragma: no cover
-                    if hasattr(e, 'message') and (
-                        'Server sent unexpected return value (502 Bad Gateway)'
-                        ' in response to PROPFIND') in e.message:
+                    if e.apr_err == core.SVN_ERR_RA_DAV_REQUEST_FAILED:
                         tries += 1
                         ui.status('Got a 502, retrying (%s)\n' % tries)
                     else:
-                        raise
+                        raise merc_util.Abort(*e.args)
     merc_util._encoding = old_encoding
 fetch_revisions = util.register_subcommand('pull')(fetch_revisions)
 
@@ -248,7 +246,7 @@ def stupid_diff_branchrev(ui, svn, hg_ed
     except svnwrap.SubversionRepoCanNotDiff:
         raise BadPatchApply('subversion diffing code is not supported')
     except core.SubversionException, e:
-        if (hasattr(e, 'apr_err') and e.apr_err != 160013):
+        if (hasattr(e, 'apr_err') and e.apr_err != core.SVN_ERR_FS_NOT_FOUND):
             raise
         raise BadPatchApply('previous revision does not exist')
     if '\0' in d:
@@ -609,7 +607,7 @@ def stupid_svn_server_pull_rev(ui, svn, 
                     ui, svn, hg_editor, b, r, parentctx)
             except BadPatchApply, e:
                 # Either this revision or the previous one does not exist.
-                ui.status("fetching entire rev: %s.\n" % e.message)
+                ui.status("Fetching entire revision: %s.\n" % e.args[0])
                 files_touched, filectxfn2 = stupid_fetch_branchrev(
                     svn, hg_editor, b, branches[b], r, parentctx)
 
--- a/hg_delta_editor.py
+++ b/hg_delta_editor.py
@@ -508,6 +508,7 @@ class HgChangeReceiver(delta.Editor):
         branches = {}
         for path, entry in self.externals.iteritems():
             if not self._is_path_valid(path):
+                self.ui.warn('WARNING: Invalid path %s in externals\n' % path)
                 continue
             p, b, bp = self._split_branch_path(path)
             if bp not in branches:
@@ -838,6 +839,8 @@ class HgChangeReceiver(delta.Editor):
                     baserev = self.current_rev.revnum - 1
                 parent = self.get_parent_revision(baserev + 1, branch)
                 self.load_base_from_ctx(path, fpath, self.repo.changectx(parent))
+        else:
+            self.ui.warn('WARNING: Opening non-existant file %s\n' % path)
     open_file = stash_exception_on_self(open_file)
 
     def aresamefiles(self, parentctx, childctx, files):
@@ -1022,11 +1025,10 @@ class HgChangeReceiver(delta.Editor):
                 if not window:
                     self.current_files[self.current_file] = target.getvalue()
             except core.SubversionException, e: #pragma: no cover
-                if e.message == 'Delta source ended unexpectedly':
+                if e.apr_err == core.SVN_ERR_INCOMPLETE_DATA:
                     self.missing_plaintexts.add(self.current_file)
                 else: #pragma: no cover
-                    self._exception_info = sys.exc_info()
-                    raise
+                    raise util.Abort(*e.args)
             except: #pragma: no cover
                 print len(base), self.current_file
                 self._exception_info = sys.exc_info()
--- a/svncommand.py
+++ b/svncommand.py
@@ -5,7 +5,6 @@ import traceback
 
 from mercurial import hg
 from mercurial import node
-from mercurial import util as merc_util
 
 import svnwrap
 import util
--- a/svnwrap/svn_swig_wrapper.py
+++ b/svnwrap/svn_swig_wrapper.py
@@ -189,7 +189,7 @@ class SubversionRepo(object):
         try:
             tags = self.list_dir('tags', revision=revision).keys()
         except core.SubversionException, e:
-            if e.apr_err == 160013:
+            if e.apr_err == core.SVN_ERR_FS_NOT_FOUND:
                 return {}
             raise
         tag_info = {}
@@ -386,10 +386,8 @@ class SubversionRepo(object):
                       e_baton, self.pool)
         except core.SubversionException, e: #pragma: no cover
             # can I depend on this number being constant?
-            if (e.message == "Server doesn't support the replay command"
-                or e.apr_err == 170003
-                or e.message == 'The requested report is unknown.'
-                or e.apr_err == 200007):
+            if (e.apr_err == core.SVN_ERR_RA_NOT_IMPLEMENTED or
+                e.apr_err == core.SVN_ERR_UNSUPPORTED_FEATURE):
                 raise SubversionRepoCanNotReplay, ('This Subversion server '
                    'is older than 1.4.0, and cannot satisfy replay requests.')
             else: