You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2011/04/14 00:19:10 UTC

svn commit: r1091933 - in /subversion/trunk/subversion: libsvn_client/client.h libsvn_client/commit.c libsvn_client/commit_util.c libsvn_client/copy.c tests/cmdline/commit_tests.py

Author: rhuijben
Date: Wed Apr 13 22:19:09 2011
New Revision: 1091933

URL: http://svn.apache.org/viewvc?rev=1091933&view=rev
Log:
Following up on r1091928 and r841618 (aka r1544), make sure commits are
performed on the right repository by finally using the repository_root
as the hash key in the commit processor.

* subversion/libsvn_client/client.h
  (SVN_CLIENT__SINGLE_REPOS_NAME): Remove define.

* subversion/libsvn_client/commit.c
  (svn_client_commit5): Explicitly detect multi repository commits and
    provide a user understandable error.

* subversion/libsvn_client/commit_util.c
  (add_committable): Use the repos_root_url as the key.
  (svn_client__harvest_committables): Don't assume a single repos_root.

* subversion/libsvn_client/copy.c
  (wc_to_repos_copy): Capture the commit items properly.

* subversion/tests/cmdline/commit_tests.py
  (commit_multiple_wc_multiple_repos): Remove broken XFail marker.

Modified:
    subversion/trunk/subversion/libsvn_client/client.h
    subversion/trunk/subversion/libsvn_client/commit.c
    subversion/trunk/subversion/libsvn_client/commit_util.c
    subversion/trunk/subversion/libsvn_client/copy.c
    subversion/trunk/subversion/tests/cmdline/commit_tests.py

Modified: subversion/trunk/subversion/libsvn_client/client.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/client.h?rev=1091933&r1=1091932&r2=1091933&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/client.h (original)
+++ subversion/trunk/subversion/libsvn_client/client.h Wed Apr 13 22:19:09 2011
@@ -780,17 +780,6 @@ typedef struct svn_client__copy_pair_t
 
 */
 
-
-
-/* ### This is TEMPORARY! Until we can find out the canonical
-   repository URL of a given entry, we'll just use this bogus value in
-   for our single committables hash key.  By the time we support
-   multiple repositories we will have to be storing the canonical
-   repository URLs anyway, so this will go away and the real URLs will
-   be the keys of the committables hash. */
-#define SVN_CLIENT__SINGLE_REPOS_NAME "svn:single-repos"
-
-
 /* Recursively crawl a set of working copy paths (DIR_ABSPATH + each
    item in the TARGETS array) looking for commit candidates, locking
    working copy directories as the crawl progresses.  For each

Modified: subversion/trunk/subversion/libsvn_client/commit.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/commit.c?rev=1091933&r1=1091932&r2=1091933&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/commit.c (original)
+++ subversion/trunk/subversion/libsvn_client/commit.c Wed Apr 13 22:19:09 2011
@@ -1249,16 +1249,24 @@ svn_client_commit5(const apr_array_heade
   if (cmt_err)
     goto cleanup;
 
-  /* ### todo: Currently there should be only one hash entry, which
-     has a hacked name until we have the entries files storing
-     canonical repository URLs.  Then, the hacked name can go away
-     and be replaced with a canonical repos URL, and from there we
-     are poised to started handling nested working copies.  See
-     http://subversion.tigris.org/issues/show_bug.cgi?id=960. */
-  if (! ((commit_items = apr_hash_get(committables,
-                                      SVN_CLIENT__SINGLE_REPOS_NAME,
-                                      APR_HASH_KEY_STRING))))
-    goto cleanup;
+  if (apr_hash_count(committables) == 0)
+    {
+      goto cleanup; /* Nothing to do */
+    }
+  else if (apr_hash_count(committables) > 1)
+    {
+      cmt_err = svn_error_create(
+             SVN_ERR_UNSUPPORTED_FEATURE, NULL,
+             _("Commit can only commit to a single repository at a time.\n"
+               "Are all targets part of the same working copy?"));
+      goto cleanup;
+    }
+
+  {
+    apr_hash_index_t *hi = apr_hash_first(iterpool, committables);
+
+    commit_items = svn__apr_hash_index_val(hi);
+  }
 
   /* If our array of targets contains only locks (and no actual file
      or prop modifications), then we return here to avoid committing a

Modified: subversion/trunk/subversion/libsvn_client/commit_util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/commit_util.c?rev=1091933&r1=1091932&r2=1091933&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/commit_util.c (original)
+++ subversion/trunk/subversion/libsvn_client/commit_util.c Wed Apr 13 22:19:09 2011
@@ -87,7 +87,6 @@ add_committable(apr_hash_t *committables
                 apr_pool_t *result_pool,
                 apr_pool_t *scratch_pool)
 {
-  const char *repos_name = SVN_CLIENT__SINGLE_REPOS_NAME;
   apr_array_header_t *array;
   svn_client_commit_item3_t *new_item;
 
@@ -98,14 +97,15 @@ add_committable(apr_hash_t *committables
   /* ### todo: Get the canonical repository for this item, which will
      be the real key for the COMMITTABLES hash, instead of the above
      bogosity. */
-  array = apr_hash_get(committables, repos_name, APR_HASH_KEY_STRING);
+  array = apr_hash_get(committables, repos_root_url, APR_HASH_KEY_STRING);
 
   /* E-gads!  There is no array for this repository yet!  Oh, no
      problem, we'll just create (and add to the hash) one. */
   if (array == NULL)
     {
       array = apr_array_make(result_pool, 1, sizeof(new_item));
-      apr_hash_set(committables, repos_name, APR_HASH_KEY_STRING, array);
+      apr_hash_set(committables, apr_pstrdup(result_pool, repos_root_url),
+                   APR_HASH_KEY_STRING, array);
     }
 
   /* Now update pointer values, ensuring that their allocations live
@@ -783,7 +783,6 @@ svn_client__harvest_committables(apr_has
   int i;
   apr_pool_t *iterpool = svn_pool_create(scratch_pool);
   apr_hash_t *changelist_hash = NULL;
-  const char *repos_root_url = NULL;
   svn_wc_context_t *wc_ctx = ctx->wc_ctx;
 
   /* It's possible that one of the named targets has a parent that is
@@ -829,6 +828,7 @@ svn_client__harvest_committables(apr_has
       const char *repos_relpath, *target_abspath;
       svn_boolean_t is_added;
       svn_node_kind_t kind;
+      const char *repos_root_url;
       svn_error_t *err;
 
       svn_pool_clear(iterpool);
@@ -862,8 +862,7 @@ svn_client__harvest_committables(apr_has
                        svn_dirent_local_style(target_abspath, iterpool));
         }
 
-      if (!repos_root_url)
-        SVN_ERR(svn_wc__node_get_repos_info(&repos_root_url, NULL, wc_ctx,
+      SVN_ERR(svn_wc__node_get_repos_info(&repos_root_url, NULL, wc_ctx,
                                             target_abspath, TRUE, TRUE,
                                             result_pool, iterpool));
 

Modified: subversion/trunk/subversion/libsvn_client/copy.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/copy.c?rev=1091933&r1=1091932&r2=1091933&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/copy.c (original)
+++ subversion/trunk/subversion/libsvn_client/copy.c Wed Apr 13 22:19:09 2011
@@ -1299,17 +1299,16 @@ wc_to_repos_copy(const apr_array_header_
                                             copy_pairs,
                                             ctx, pool, pool));
 
-  /* ### todo: There should be only one hash entry, which currently
-     has a hacked name until we have the entries files storing
-     canonical repository URLs.  Then, the hacked name can go away and
-     be replaced with a entry->repos (or wherever the entry's
-     canonical repos URL is stored). */
-  if (! (commit_items = apr_hash_get(committables,
-                                     SVN_CLIENT__SINGLE_REPOS_NAME,
-                                     APR_HASH_KEY_STRING)))
-    {
-      return SVN_NO_ERROR;
-    }
+  /* The committables are keyed by the repository root */
+  {
+    const char *repos_root_url;
+    SVN_ERR(svn_ra_get_repos_root2(ra_session, &repos_root_url, pool));
+
+    commit_items = apr_hash_get(committables, repos_root_url,
+                                APR_HASH_KEY_STRING);
+
+    SVN_ERR_ASSERT(commit_items != NULL);
+  }
 
   /* If we are creating intermediate directories, tack them onto the list
      of committables. */

Modified: subversion/trunk/subversion/tests/cmdline/commit_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/commit_tests.py?rev=1091933&r1=1091932&r2=1091933&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/commit_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/commit_tests.py Wed Apr 13 22:19:09 2011
@@ -1478,7 +1478,6 @@ def commit_multiple_wc(sbox):
 # from different repositories. Commits to multiple repositories
 # are outside the scope of issue #2381.
 @Issue(2381)
-@XFail
 def commit_multiple_wc_multiple_repos(sbox):
   "committing two WCs from different repos fails"
 



Re: svn commit: r1091933 - in /subversion/trunk/subversion: libsvn_client/client.h libsvn_client/commit.c libsvn_client/commit_util.c libsvn_client/copy.c tests/cmdline/commit_tests.py

Posted by "C. Michael Pilato" <cm...@collab.net>.
On 04/13/2011 06:19 PM, rhuijben@apache.org wrote:
> Author: rhuijben
> Date: Wed Apr 13 22:19:09 2011
> New Revision: 1091933
> 
> URL: http://svn.apache.org/viewvc?rev=1091933&view=rev
> Log:
> Following up on r1091928 and r841618 (aka r1544), make sure commits are
> performed on the right repository by finally using the repository_root
> as the hash key in the commit processor.

WOW!  Amazing to see that when I "coded for the future" way back in the day
with this whole hash-of-per-repos-committables stuff, it actually managed to
work out without too much additional tweaking!

-- 
C. Michael Pilato <cm...@collab.net>
CollabNet   <>   www.collab.net   <>   Distributed Development On Demand


Re: svn commit: r1091933 - in /subversion/trunk/subversion: libsvn_client/client.h libsvn_client/commit.c libsvn_client/commit_util.c libsvn_client/copy.c tests/cmdline/commit_tests.py

Posted by "C. Michael Pilato" <cm...@collab.net>.
On 04/13/2011 06:19 PM, rhuijben@apache.org wrote:
> Author: rhuijben
> Date: Wed Apr 13 22:19:09 2011
> New Revision: 1091933
> 
> URL: http://svn.apache.org/viewvc?rev=1091933&view=rev
> Log:
> Following up on r1091928 and r841618 (aka r1544), make sure commits are
> performed on the right repository by finally using the repository_root
> as the hash key in the commit processor.

WOW!  Amazing to see that when I "coded for the future" way back in the day
with this whole hash-of-per-repos-committables stuff, it actually managed to
work out without too much additional tweaking!

-- 
C. Michael Pilato <cm...@collab.net>
CollabNet   <>   www.collab.net   <>   Distributed Development On Demand