This patch breaks the following functionality:
svn import -m "" empty-dir URL-OF-REPOS/new-dir
As I mentioned in IRC yesterday, doing this right does not involve
checking for empty directories -- it involves the import driver
remembering (perhaps as a boolean in some context structure) if it
ever actually did anything in the repository (probably as simple as
remembering if "add_file" or "add_directory" was called), and if not,
then call abort_edit() instead of close_edit().
"S.Ramaswamy" <ramaswamy@collab.net> writes:
> Patch to avoid creating empty revisions - revisions with no path changes.
> Currently 'svn import' allows empty paths to be imported, creating
> revisions with no path changes. Not sure if basic_tests.py is the right
> place for the test.
>
> Ramaswamy
>
> ChangeLog :
>
>
> * subversion/libsvn_client/commit.c
> (import) : Abort an edit if the path is an empty directory to avoid
> creating empty revisions.
>
> * subversion/tests/clients/cmdline/basic_tests.py
> (basic_import_empty_dir) : New. Verify that an empty directory cannot
> be imported.
>
> (test_list) : Added basic_import_empty_dir to list of tests.
>
>
>
>
>
>
> Index: subversion/libsvn_client/commit.c
> ===================================================================
> --- subversion/libsvn_client/commit.c (revision 13961)
> +++ subversion/libsvn_client/commit.c (working copy)
> @@ -437,6 +437,7 @@
> apr_array_header_t *ignores;
> apr_array_header_t *batons = NULL;
> const char *edit_path = "";
> + svn_boolean_t is_empty_dir;
>
> /* Get a root dir baton. We pass an invalid revnum to open_root
> to mean "base this on the youngest revision". Should we have an
> @@ -518,8 +519,14 @@
> }
> }
>
> - SVN_ERR (editor->close_edit (edit_baton, pool));
> + if (kind == svn_node_dir)
> + SVN_ERR (svn_io_dir_empty (&is_empty_dir, path, pool));
>
> + if ((kind == svn_node_dir) && (is_empty_dir))
> + SVN_ERR (editor->abort_edit (edit_baton, pool));
> + else
> + SVN_ERR (editor->close_edit (edit_baton, pool));
> +
> return SVN_NO_ERROR;
> }
>
> Index: subversion/tests/clients/cmdline/basic_tests.py
> ===================================================================
> --- subversion/tests/clients/cmdline/basic_tests.py (revision 13961)
> +++ subversion/tests/clients/cmdline/basic_tests.py (working copy)
> @@ -1632,7 +1632,35 @@
> else:
> raise svntest.Failure
>
> +#----------------------------------------------------------------------
> +def basic_import_empty_dir(sbox):
> + "verify that an empty dir cannot be imported"
> +
> + sbox.build()
> + wc_dir = sbox.wc_dir
>
> + # create a new directory
> + empty_dir = os.path.join(wc_dir, "empty_dir")
> + os.makedirs(empty_dir)
> +
> + url = svntest.main.current_repo_url
> + svntest.actions.run_and_verify_svn(None, None, None, 'import',
> + '--username', svntest.main.wc_author,
> + '--password', svntest.main.wc_passwd,
> + '-m', 'Log message for new import',
> + empty_dir, url)
> +
> + svntest.main.safe_rmtree(empty_dir)
> +
> + # Verify that the empty directory has not been imported with
> + # an update.
> + svntest.actions.run_and_verify_svn(None, [ "At revision 1.\n"],
> + None, "update",
> + '--username', svntest.main.wc_author,
> + '--password', svntest.main.wc_passwd,
> + empty_dir)
> +
> +#----------------------------------------------------------------------
> ########################################################################
> # Run the tests
>
> @@ -1663,6 +1691,7 @@
> basic_import_ignores,
> uri_syntax,
> basic_checkout_file,
> + basic_import_empty_dir,
> ### todo: more tests needed:
> ### test "svn rm http://some_url"
> ### not sure this file is the right place, though.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: dev-help@subversion.tigris.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Apr 6 22:43:22 2005