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