Index: subversion/libsvn_client/add.c =================================================================== --- subversion/libsvn_client/add.c (revision 21223) +++ subversion/libsvn_client/add.c (working copy) @@ -322,12 +322,40 @@ /* Read the directory entries one by one and add those things to revision control. */ SVN_ERR(svn_io_dir_open(&dir, dirname, pool)); - for (err = svn_io_dir_read(&this_entry, flags, dir, subpool); - err == SVN_NO_ERROR; - err = svn_io_dir_read(&this_entry, flags, dir, subpool)) + + while (1) { const char *fullpath; + /* Clean out the per-iteration pool. */ + svn_pool_clear(subpool); + + err = svn_io_dir_read(&this_entry, flags, dir, subpool); + + if (err) + { + /* Check that the loop exited cleanly. */ + if (! (APR_STATUS_IS_ENOENT(err->apr_err))) + { + return svn_error_createf + (err->apr_err, err, + _("Error during recursive add of '%s'"), + svn_path_local_style(dirname, subpool)); + } + else /* Yes, it exited cleanly, so close the dir. */ + { + apr_status_t apr_err; + + svn_error_clear(err); + apr_err = apr_dir_close(dir); + if (apr_err) + return svn_error_wrap_apr + (apr_err, _("Can't close directory '%s'"), + svn_path_local_style(dirname, subpool)); + } + break; + } + /* Skip entries for this dir and its parent. */ if (this_entry.name[0] == '.' && (this_entry.name[1] == '\0' @@ -364,31 +392,8 @@ else if (err) return err; } - - /* Clean out the per-iteration pool. */ - svn_pool_clear(subpool); } - /* Check that the loop exited cleanly. */ - if (! (APR_STATUS_IS_ENOENT(err->apr_err))) - { - return svn_error_createf - (err->apr_err, err, - _("Error during recursive add of '%s'"), - svn_path_local_style(dirname, subpool)); - } - else /* Yes, it exited cleanly, so close the dir. */ - { - apr_status_t apr_err; - - svn_error_clear(err); - apr_err = apr_dir_close(dir); - if (apr_err) - return svn_error_wrap_apr - (apr_err, _("Can't close directory '%s'"), - svn_path_local_style(dirname, subpool)); - } - /* Opened by svn_wc_add */ SVN_ERR(svn_wc_adm_close(dir_access)); --=_mixed 004D7F3A852571D3_Content-Type: text/plain; name="wc.copy.loop.fix.diff.txt" Content-Disposition: attachment; filename="wc.copy.loop.fix.diff.txt" Content-Transfer-Encoding: quoted-printable Index: subversion/libsvn_wc/copy.c =================================================================== --- subversion/libsvn_wc/copy.c (revision 21223) +++ subversion/libsvn_wc/copy.c (working copy) @@ -161,17 +161,48 @@ SVN_ERR(svn_wc_adm_retrieve(&src_child_dir_access, src_access, src_path, pool)); + /* Read src_path's entries one by one. */ + SVN_ERR(svn_io_dir_open(&dir, src_path, pool)); + /* Create a subpool for iterative memory control. */ subpool = svn_pool_create(pool); - /* Read src_path's entries one by one. */ - SVN_ERR(svn_io_dir_open(&dir, src_path, pool)); - for (err = svn_io_dir_read(&this_entry, flags, dir, subpool); - err == SVN_NO_ERROR; - err = svn_io_dir_read(&this_entry, flags, dir, subpool)) + while (1) { const char *src_fullpath; + /* Clean out the per-iteration pool. */ + svn_pool_clear(subpool); + + err = svn_io_dir_read(&this_entry, flags, dir, subpool); + + if (err) + { + /* Check that the loop exited cleanly. */ + if (! (APR_STATUS_IS_ENOENT(err->apr_err))) + { + return svn_error_createf(err->apr_err, err, + _("Error during recursive copy " + "of '%s'"), + svn_path_local_style(src_path, + subpool)); + } + else /* Yes, it exited cleanly, so close the dir. */ + { + apr_status_t apr_err; + + svn_error_clear(err); + apr_err = apr_dir_close(dir); + if (apr_err) + return svn_error_wrap_apr(apr_err, + _("Can't close " + "directory '%s'"), + svn_path_local_style(src_path, + subpool)); + } + break; + } + /* Skip entries for this dir and its parent. */ if (this_entry.name[0] == '.' && (this_entry.name[1] == '\0' @@ -221,32 +252,10 @@ subpool)); } - /* Clean out the per-iteration pool. */ - svn_pool_clear(subpool); + } /* End while(1) loop */ - } /* End for loop */ + svn_pool_destroy(subpool); - /* Check that the loop exited cleanly. */ - if (! (APR_STATUS_IS_ENOENT(err->apr_err))) - { - return svn_error_createf(err->apr_err, err, - _("Error during recursive copy of '%s'"), - svn_path_local_style(src_path, - subpool)); - } - else /* Yes, it exited cleanly, so close the dir. */ - { - apr_status_t apr_err; - - svn_error_clear(err); - apr_err = apr_dir_close(dir); - if (apr_err) - return svn_error_wrap_apr(apr_err, - _("Can't close directory '%s'"), - svn_path_local_style(src_path, - subpool)); - } - } /* End else src_is_added. */ return SVN_NO_ERROR;