changeset 557:d74bf020a61c

replay/stupid: raise the correct errno in IOError to fix hg >= e553a425751d Basically, all the IOErrors we ever raise inside a file commit function that is sent to commitctx should be ENOENT. This suggests a change should be made in commitctx to not overload IOError.
author Augie Fackler <durin42@gmail.com>
date Sun, 14 Feb 2010 14:04:56 -0600
parents 8522f8ef799e
children e841e65390d0
files hgsubversion/replay.py hgsubversion/stupid.py tests/test_push_command.py
diffstat 3 files changed, 7 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/replay.py
+++ b/hgsubversion/replay.py
@@ -144,8 +144,7 @@ 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(errno.EBADF,
-                              'Operation on deleted file attempted')
+                raise IOError(errno.ENOENT, '%s is deleted' % path)
             copied = current.copies.get(current_file)
             flags = parentctx.flags(path)
             is_exec = current.execfiles.get(current_file, 'x' in flags)
@@ -192,7 +191,7 @@ def convert_rev(ui, meta, svn, r, tbdelt
 
         parent_ctx = meta.repo.changectx(ha)
         def del_all_files(*args):
-            raise IOError
+            raise IOError(errno.ENOENT, 'deleting all files')
 
         # True here meant nuke all files, shouldn't happen with branch closing
         if current.emptybranches[branch]: #pragma: no cover
--- a/hgsubversion/stupid.py
+++ b/hgsubversion/stupid.py
@@ -224,7 +224,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(errno.EBADF, 'No data configured for file ' + path)
+            raise IOError(errno.ENOENT, '%s is deleted' % path)
 
         if path in binary_files or path in unknown_files:
             pa = path
@@ -597,14 +597,12 @@ def convert_rev(ui, meta, svn, r, tbdelt
         def filectxfn(repo, memctx, path):
             if path == '.hgsvnexternals':
                 if not externals:
-                    raise IOError(errno.EINVAL,
-                                  '.hgsvnexternals exists, but externals are '
-                                  'not configured')
+                    raise IOError(errno.ENOENT, 'no externals')
                 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(errno.EINVAL, 'Path %s is bad' % path)
+                    raise IOError(errno.ENOENT, 'Path %s is bad' % path)
             return filectxfn2(repo, memctx, path)
 
         if '' in files_touched:
--- a/tests/test_push_command.py
+++ b/tests/test_push_command.py
@@ -55,7 +55,7 @@ class PushTests(test_util.TestBase):
         repo = self.repo
         def file_callback(repo, memctx, path):
             return context.memfilectx(
-                path=path, data='foo', islink=False, 
+                path=path, data='foo', islink=False,
                 isexec=False, copied=False)
         ctx = context.memctx(repo,
                              (repo['default'].node(), node.nullid),
@@ -302,7 +302,7 @@ class PushTests(test_util.TestBase):
     def test_delete_file(self):
         repo = self.repo
         def file_callback(repo, memctx, path):
-            raise IOError(errno.EBADF, 'Operation on deleted file attempted')
+            raise IOError(errno.ENOENT, '%s is deleted' % path)
         old_files = set(repo['default'].manifest().keys())
         ctx = context.memctx(repo,
                              (repo['default'].node(), node.nullid),