# HG changeset patch # User Dan Villiom Podlaski Christiansen # Date 1264523773 -3600 # Node ID cf4fe45bf8fd81d186c4d85e7be920a15a8f4ff5 # Parent 76e9504db03b19a91f564aaa04efc87ffb3fbfe1 Change all instantiations of IOError to set both errno and strerror. diff --git a/hgsubversion/replay.py b/hgsubversion/replay.py --- a/hgsubversion/replay.py +++ b/hgsubversion/replay.py @@ -1,3 +1,4 @@ +import errno import traceback from mercurial import revlog @@ -138,7 +139,8 @@ def convert_rev(ui, meta, svn, r, tbdelt def filectxfn(repo, memctx, path): current_file = files[path] if current_file in current.deleted: - raise IOError() + raise IOError(errno.EBADF, + 'Operation on deleted file attempted') copied = current.copies.get(current_file) flags = parentctx.flags(path) is_exec = current.execfiles.get(current_file, 'x' in flags) diff --git a/hgsubversion/stupid.py b/hgsubversion/stupid.py --- a/hgsubversion/stupid.py +++ b/hgsubversion/stupid.py @@ -1,4 +1,5 @@ import cStringIO +import errno import re from mercurial import patch @@ -60,7 +61,7 @@ def mempatchproxy(parentctx, files): def readlines(self, fname): if fname not in parentctx: - raise IOError('Cannot find %r to patch' % fname) + raise IOError(errno.ENOENT, 'Cannot find %r to patch' % fname) fctx = parentctx[fname] data = fctx.data() if 'l' in fctx.flags(): @@ -226,7 +227,7 @@ def diff_branchrev(ui, svn, meta, branch def filectxfn(repo, memctx, path): if path in files_data and files_data[path] is None: - raise IOError() + raise IOError(errno.EBADF, 'No data configured for file ' + path) if path in binary_files or path in unknown_files: pa = path @@ -595,12 +596,14 @@ def convert_rev(ui, meta, svn, r, tbdelt def filectxfn(repo, memctx, path): if path == '.hgsvnexternals': if not externals: - raise IOError() + raise IOError(errno.EINVAL, + '.hgsvnexternals exists, but externals are ' + 'not configured') return context.memfilectx(path=path, data=externals.write(), islink=False, isexec=False, copied=None) for bad in bad_branch_paths[b]: if path.startswith(bad): - raise IOError() + raise IOError(errno.EINVAL, 'Path %s is bad' % path) return filectxfn2(repo, memctx, path) if '' in files_touched: diff --git a/hgsubversion/svnwrap/svn_swig_wrapper.py b/hgsubversion/svnwrap/svn_swig_wrapper.py --- a/hgsubversion/svnwrap/svn_swig_wrapper.py +++ b/hgsubversion/svnwrap/svn_swig_wrapper.py @@ -1,5 +1,6 @@ import cStringIO import getpass +import errno import os import shutil import sys @@ -574,8 +575,8 @@ class SubversionRepo(object): except core.SubversionException, e: notfound = (core.SVN_ERR_FS_NOT_FOUND, core.SVN_ERR_RA_DAV_PATH_NOT_FOUND) - if e.apr_err in notfound: # File not found - raise IOError() + if e.args[1] in notfound: # File not found + raise IOError(errno.ENOENT, e.args[0]) raise if mode == 'l': linkprefix = "link " @@ -596,7 +597,7 @@ class SubversionRepo(object): except core.SubversionException, e: # Specified path does not exist at this revision if e.apr_err == core.SVN_ERR_NODE_UNKNOWN_KIND: - raise IOError() + raise IOError(errno.ENOENT, e.args[0]) raise if not pl: return {} @@ -623,7 +624,8 @@ class SubversionRepo(object): entries = client.ls(rpath, rev, True, self.client_context, pool) except core.SubversionException, e: if e.apr_err == core.SVN_ERR_FS_NOT_FOUND: - raise IOError('%s cannot be found at r%d' % (dirpath, revision)) + raise IOError(errno.ENOENT, + '%s cannot be found at r%d' % (dirpath, revision)) raise for path, e in entries.iteritems(): kind = _svntypes.get(e.kind) diff --git a/tests/test_push_command.py b/tests/test_push_command.py --- a/tests/test_push_command.py +++ b/tests/test_push_command.py @@ -1,4 +1,5 @@ import atexit +import errno import os import random import shutil @@ -106,7 +107,7 @@ class PushTests(test_util.TestBase): islink=False, isexec=False, copied=False) - raise IOError() + raise IOError(errno.EINVAL, 'Invalid operation: ' + path) ctx = context.memctx(repo, parents=(repo['default'].node(), node.nullid), text='automated test', @@ -145,7 +146,7 @@ class PushTests(test_util.TestBase): islink=False, isexec=False, copied=False) - raise IOError() + raise IOError(errno.EINVAL, 'Invalid operation: ' + path) ctx = context.memctx(repo, (repo['default'].node(), node.nullid), 'automated test', @@ -213,7 +214,7 @@ class PushTests(test_util.TestBase): islink=False, isexec=False, copied=False) - raise IOError() + raise IOError(errno.EINVAL, 'Invalid operation: ' + path) ctx = context.memctx(repo, (repo['default'].node(), node.nullid), 'automated test', @@ -248,7 +249,7 @@ class PushTests(test_util.TestBase): islink=False, isexec=False, copied=False) - raise IOError() + raise IOError(errno.EINVAL, 'Invalid operation: ' + path) ctx = context.memctx(repo, (repo['the_branch'].node(), node.nullid), 'automated test', @@ -301,7 +302,7 @@ class PushTests(test_util.TestBase): def test_delete_file(self): repo = self.repo def file_callback(repo, memctx, path): - raise IOError() + raise IOError(errno.EBADF, 'Operation on deleted file attempted') old_files = set(repo['default'].manifest().keys()) ctx = context.memctx(repo, (repo['default'].node(), node.nullid), @@ -329,7 +330,7 @@ class PushTests(test_util.TestBase): islink=False, isexec=True, copied=False) - raise IOError() + raise IOError(errno.EINVAL, 'Invalid operation: ' + path) ctx = context.memctx(repo, (repo['tip'].node(), node.nullid), 'message', @@ -359,7 +360,7 @@ class PushTests(test_util.TestBase): islink=True, isexec=False, copied=False) - raise IOError() + raise IOError(errno.EINVAL, 'Invalid operation: ' + path) ctx = context.memctx(repo, (repo['tip'].node(), node.nullid), 'message', diff --git a/tests/test_single_dir_clone.py b/tests/test_single_dir_clone.py --- a/tests/test_single_dir_clone.py +++ b/tests/test_single_dir_clone.py @@ -1,3 +1,4 @@ +import errno import shutil from mercurial import commands @@ -90,7 +91,7 @@ class TestSingleDir(test_util.TestBase): islink=False, isexec=False, copied=False) - raise IOError() + raise IOError(errno.EINVAL, 'Invalid operation: ' + path) ctx = context.memctx(repo, (repo['tip'].node(), node.nullid), 'automated test', @@ -150,7 +151,7 @@ class TestSingleDir(test_util.TestBase): islink=False, isexec=False, copied=False) - raise IOError() + raise IOError(errno.EINVAL, 'Invalid operation: ' + path) return cb def commit_to_branch(name, parent): diff --git a/tests/test_util.py b/tests/test_util.py --- a/tests/test_util.py +++ b/tests/test_util.py @@ -240,7 +240,8 @@ class TestBase(unittest.TestCase): def filectxfn(repo, memctx, path): if path in removed: - raise IOError() + raise IOError(errno.ENOENT, + "File \"%s\" no longer exists" % path) entry = [e for e in changes if path == e[1]][0] source, dest, newdata = entry if newdata is None: