Maybe update this log message to say this revision was (partially?)
reverted. ??
On Sat, Feb 21, 2009 at 02:27, Bert Huijben <rhuijben_at_sharpsvn.net> wrote:
> Author: rhuijben
> Date: Fri Feb 20 17:27:40 2009
> New Revision: 36037
>
> Log:
> In preparation for fixing issue #2556 (and as part of issue #1711), add
> functions to split a dirent in a path and an entry name (the name of the
> entry as it is known in its parent). This will allow handling drive roots
> (E.g. "G:/" on Windows) like normal paths..
>
> Note that svn_dirent_entryname and svn_dirent_splitentry are almost
> identical to svn_dirent_basename and svn_dirent_split, with roots as
> notable exception.
>
> Generally client libraries should use the basename variants while the
> administrative area handling should use the entryname variants.
>
> * subversion/include/svn_dirent_uri.h
> (svn_dirent_entryname): New function.
> (svn_dirent_splitentry): New function.
> * subversion/libsvn_subr/dirent_uri.c
> (svn_dirent_entryname): New function.
> (svn_dirent_splitentry): New function.
> * subversion/tests/libsvn_subr/dirent_uri-test.c
> (test_dirent_entryname): New function.
> (test_dirent_splitentry): New function.
> (test_funcs): Add test_dirent_entryname and
> test_dirent_splitentry.
>
> Modified:
> trunk/subversion/include/svn_dirent_uri.h
> trunk/subversion/libsvn_subr/dirent_uri.c
> trunk/subversion/tests/libsvn_subr/dirent_uri-test.c
>
> Modified: trunk/subversion/include/svn_dirent_uri.h
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/include/svn_dirent_uri.h?pathrev=36037&r1=36036&r2=36037
> ==============================================================================
> --- trunk/subversion/include/svn_dirent_uri.h Fri Feb 20 15:08:54 2009 (r36036)
> +++ trunk/subversion/include/svn_dirent_uri.h Fri Feb 20 17:27:40 2009 (r36037)
> @@ -151,6 +151,18 @@ char *
> svn_dirent_basename(const char *dirent,
> apr_pool_t *pool);
>
> +/** Gets the name of the specified canonicalized @a dirent as it is known
> + * within its parent directory. If the @a dirent is root, return "". The
> + * returned value will not have slashes in it.
> + *
> + * Where @a dirent doesn't specify a root, it's value is identical to that
> + * returned by svn_dirent_basename()
> + *
> + * @since New in 1.7.
> + */
> +char *
> +svn_dirent_entryname(const char *dirent,
> + apr_pool_t *pool);
>
> /** Get the dirname of the specified canonicalized @a dirent, defined as
> * the dirent with its basename removed.
> @@ -177,16 +189,16 @@ svn_dirent_dirname(const char *dirent,
> * If @a dirent has two or more components, the separator between @a dirpath
> * and @a base_name is not included in either of the new names.
> *
> - * examples:
> + * Examples:
> * - <pre>"/foo/bar/baz" ==> "/foo/bar" and "baz"</pre>
> * - <pre>"/bar" ==> "/" and "bar"</pre>
> * - <pre>"/" ==> "/" and "/"</pre>
> * - <pre>"bar" ==> "" and "bar"</pre>
> * - <pre>"" ==> "" and ""</pre>
> - * - <pre>"X:/" ==> "X:/" and "X:/"</pre>
> + * Windows: - <pre>"X:/" ==> "X:/" and "X:/"</pre>
> * - <pre>"X:/foo" ==> "X:/" and "foo"</pre>
> - * posix: - <pre>"X:foo" ==> "X:" and "foo"</pre>
> - * windows: - <pre>"X:foo" ==> "" and "X:foo"</pre>
> + * - <pre>"X:foo" ==> "X:" and "foo"</pre>
> + * Posix: - <pre>"X:foo" ==> "" and "X:foo"</pre>
> *
> * @since New in 1.6.
> */
> @@ -196,6 +208,39 @@ svn_dirent_split(const char *dirent,
> const char **base_name,
> apr_pool_t *pool);
>
> +/** Divide the canonicalized @a dirent into @a *dirpath and @a entry_name,
> + * allocated in @a pool.
> + *
> + * If @a dirpath or @a entry_name is NULL, then don't set that one.
> + *
> + * Either @a dirpath or @a entry_name may be @a dirent's own address, but they
> + * may not both be the same address, or the results are undefined.
> + *
> + * @a entry_name is the name of @dirent as it is known in its parent directory
> + * @a dirpath. If @a dirent specifies a root directory @a entry_name is ""
> + *
> + * If @a dirent has two or more components, the separator between @a dirpath
> + * and @a base_name is not included in either of the new names.
> + *
> + * Examples:
> + * - <pre>"/foo/bar/baz" ==> "/foo/bar" and "baz"</pre>
> + * - <pre>"/bar" ==> "/" and "bar"</pre>
> + * - <pre>"/" ==> "/" and ""</pre>
> + * - <pre>"bar" ==> "" and "bar"</pre>
> + * - <pre>"" ==> "" and ""</pre>
> + * Windows: - <pre>"X:/" ==> "X:/" and ""</pre>
> + * - <pre>"X:/foo" ==> "X:/" and "foo"</pre>
> + * - <pre>"X:foo" ==> "X:" and "foo"</pre>
> + * Posix: - <pre>"X:foo" ==> "" and "X:foo"</pre>
> + *
> + * @since New in 1.7.
> + */
> +void
> +svn_dirent_splitentry(const char *dirent,
> + const char **dirpath,
> + const char **entry_name,
> + apr_pool_t *pool);
> +
> /** Divide the canonicalized @a uri into @a *dirpath and @a
> * *base_name, allocated in @a pool.
> *
>
> Modified: trunk/subversion/libsvn_subr/dirent_uri.c
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_subr/dirent_uri.c?pathrev=36037&r1=36036&r2=36037
> ==============================================================================
> --- trunk/subversion/libsvn_subr/dirent_uri.c Fri Feb 20 15:08:54 2009 (r36036)
> +++ trunk/subversion/libsvn_subr/dirent_uri.c Fri Feb 20 17:27:40 2009 (r36037)
> @@ -908,6 +908,30 @@ svn_dirent_basename(const char *dirent,
> return apr_pstrmemdup(pool, dirent + start, len - start);
> }
>
> +char *
> +svn_dirent_entryname(const char *dirent, apr_pool_t *pool)
> +{
> + apr_size_t len = strlen(dirent);
> + apr_size_t start;
> +
> + assert(svn_dirent_is_canonical(dirent, pool));
> +
> + if (svn_dirent_is_root(dirent, len))
> + return apr_pstrmemdup(pool, "", 0);
> + else
> + {
> + start = len;
> + while (start > 0 && dirent[start - 1] != '/'
> +#if defined(WIN32) || defined(__CYGWIN__)
> + && dirent[start - 1] != ':'
> +#endif /* WIN32 or Cygwin */
> + )
> + --start;
> + }
> +
> + return apr_pstrmemdup(pool, dirent + start, len - start);
> +}
> +
> void
> svn_dirent_split(const char *dirent,
> const char **dirpath,
> @@ -923,6 +947,21 @@ svn_dirent_split(const char *dirent,
> *base_name = svn_dirent_basename(dirent, pool);
> }
>
> +void
> +svn_dirent_splitentry(const char *dirent,
> + const char **dirpath,
> + const char **base_name,
> + apr_pool_t *pool)
> +{
> + assert(dirpath != base_name);
> +
> + if (dirpath)
> + *dirpath = svn_dirent_dirname(dirent, pool);
> +
> + if (base_name)
> + *base_name = svn_dirent_entryname(dirent, pool);
> +}
> +
> char *
> svn_uri_dirname(const char *uri, apr_pool_t *pool)
> {
> @@ -1269,3 +1308,4 @@ svn_uri_is_canonical(const char *uri, ap
>
> return TRUE;
> }
> +
>
> Modified: trunk/subversion/tests/libsvn_subr/dirent_uri-test.c
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c?pathrev=36037&r1=36036&r2=36037
> ==============================================================================
> --- trunk/subversion/tests/libsvn_subr/dirent_uri-test.c Fri Feb 20 15:08:54 2009 (r36036)
> +++ trunk/subversion/tests/libsvn_subr/dirent_uri-test.c Fri Feb 20 17:27:40 2009 (r36037)
> @@ -450,6 +450,67 @@ test_dirent_basename(const char **msg,
> }
>
> static svn_error_t *
> +test_dirent_entryname(const char **msg,
> + svn_boolean_t msg_only,
> + svn_test_opts_t *opts,
> + apr_pool_t *pool)
> +{
> + int i;
> + char *result;
> +
> + struct {
> + const char *path;
> + const char *result;
> + } tests[] = {
> + { "abc", "abc" },
> + { "/abc", "abc" },
> + { "/abc", "abc" },
> + { "/x/abc", "abc" },
> + { "/xx/abc", "abc" },
> + { "/xx/abc", "abc" },
> + { "/xx/abc", "abc" },
> + { "a", "a" },
> + { "/a", "a" },
> + { "/b/a", "a" },
> + { "/b/a", "a" },
> + { "/", "" },
> + { SVN_EMPTY_PATH, SVN_EMPTY_PATH },
> + { "X:/abc", "abc" },
> + { "X:", "" },
> +#if defined(WIN32) || defined(__CYGWIN__)
> + { "X:", "" },
> + { "X:/", "" },
> + { "X:abc", "abc" },
> + { "//srv/shr", "" },
> + { "//srv/shr/fld", "fld" },
> + { "//srv/shr/fld/subfld", "subfld" },
> +#else /* WIN32 or Cygwin */
> + { "X:", "X:" },
> + { "X:abc", "X:abc" },
> +#endif /* non-WIN32 */
> + };
> +
> + *msg = "test svn_dirent_entryname";
> + if (msg_only)
> + return SVN_NO_ERROR;
> +
> + for (i = sizeof(tests) / sizeof(tests[0]); i--; )
> + {
> + const char *path = tests[i].path;
> + const char *expect = tests[i].result;
> +
> + result = svn_dirent_entryname(path, pool);
> + if (strcmp(result, expect))
> + return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
> + "svn_dirent_entryname(\"%s\") returned "
> + "\"%s\". expected \"%s\"",
> + path, result, expect);
> + }
> +
> + return SVN_NO_ERROR;
> +}
> +
> +static svn_error_t *
> test_uri_basename(const char **msg,
> svn_boolean_t msg_only,
> svn_test_opts_t *opts,
> @@ -1019,6 +1080,70 @@ test_dirent_split(const char **msg,
> }
>
> static svn_error_t *
> +test_dirent_splitentry(const char **msg,
> + svn_boolean_t msg_only,
> + svn_test_opts_t *opts,
> + apr_pool_t *pool)
> +{
> + apr_size_t i;
> +
> + static const char * const paths[][3] = {
> + { "/foo/bar", "/foo", "bar" },
> + { "/foo/bar/ ", "/foo/bar", " " },
> + { "/foo", "/", "foo" },
> + { "foo", SVN_EMPTY_PATH, "foo" },
> + { ".bar", SVN_EMPTY_PATH, ".bar" },
> + { "/.bar", "/", ".bar" },
> + { "foo/bar", "foo", "bar" },
> + { "/foo/bar", "/foo", "bar" },
> + { "foo/bar", "foo", "bar" },
> + { "foo./.bar", "foo.", ".bar" },
> + { "../foo", "..", "foo" },
> + { SVN_EMPTY_PATH, SVN_EMPTY_PATH, SVN_EMPTY_PATH },
> + { "/flu\\b/\\blarg", "/flu\\b", "\\blarg" },
> + { "/", "/", "" },
> + { "X:/foo/bar", "X:/foo", "bar" },
> + { "X:foo/bar", "X:foo", "bar" },
> +#if defined(WIN32) || defined(__CYGWIN__)
> + { "X:/", "X:/", "" },
> + { "X:/foo", "X:/", "foo" },
> + { "X:foo", "X:", "foo" },
> + { "//srv/shr", "//srv/shr", "" },
> + { "//srv/shr/fld", "//srv/shr", "fld" },
> +#else /* WIN32 or Cygwin */
> + { "X:foo", SVN_EMPTY_PATH, "X:foo" },
> +#endif /* non-WIN32 */
> + };
> +
> + *msg = "test svn_dirent_splitentry";
> +
> + if (msg_only)
> + return SVN_NO_ERROR;
> +
> + for (i = 0; i < sizeof(paths) / sizeof(paths[0]); i++)
> + {
> + const char *dir, *base_name;
> +
> + svn_dirent_splitentry(paths[i][0], &dir, &base_name, pool);
> + if (strcmp(dir, paths[i][1]))
> + {
> + return svn_error_createf
> + (SVN_ERR_TEST_FAILED, NULL,
> + "svn_dirent_splitentry (%s) returned dirname '%s' instead of '%s'",
> + paths[i][0], dir, paths[i][1]);
> + }
> + if (strcmp(base_name, paths[i][2]))
> + {
> + return svn_error_createf
> + (SVN_ERR_TEST_FAILED, NULL,
> + "svn_dirent_splitentry (%s) returned entryname '%s' instead of '%s'",
> + paths[i][0], base_name, paths[i][2]);
> + }
> + }
> + return SVN_NO_ERROR;
> +}
> +
> +static svn_error_t *
> test_uri_split(const char **msg,
> svn_boolean_t msg_only,
> svn_test_opts_t *opts,
> @@ -1028,7 +1153,7 @@ test_uri_split(const char **msg,
>
> static const char * const paths[][3] = {
> { "http://server/foo/bar", "http://server/foo", "bar" },
> - { "http://server/dir/foo/bar", "http://server/dir/foo", "bar" },
> + { "http://server/dir/foo/bar", "http://server/dir/foo", "bar" },
> { SVN_EMPTY_PATH, SVN_EMPTY_PATH, SVN_EMPTY_PATH },
> };
>
> @@ -1673,6 +1798,7 @@ struct svn_test_descriptor_t test_funcs[
> SVN_TEST_PASS(test_uri_is_absolute),
> SVN_TEST_PASS(test_dirent_join),
> SVN_TEST_PASS(test_dirent_basename),
> + SVN_TEST_PASS(test_dirent_entryname),
> SVN_TEST_PASS(test_uri_basename),
> SVN_TEST_PASS(test_dirent_dirname),
> SVN_TEST_PASS(test_uri_dirname),
> @@ -1681,6 +1807,7 @@ struct svn_test_descriptor_t test_funcs[
> SVN_TEST_PASS(test_dirent_is_canonical),
> SVN_TEST_PASS(test_uri_is_canonical),
> SVN_TEST_PASS(test_dirent_split),
> + SVN_TEST_PASS(test_dirent_splitentry),
> SVN_TEST_PASS(test_uri_split),
> SVN_TEST_PASS(test_dirent_get_longest_ancestor),
> SVN_TEST_PASS(test_uri_get_longest_ancestor),
>
> ------------------------------------------------------
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=495&dsMessageId=1201674
>
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=1227048
Received on 2009-02-25 15:28:33 CET