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/05/02 14:50:24 UTC

svn commit: r1098542 - /subversion/trunk/subversion/libsvn_wc/wc_db.c

Author: rhuijben
Date: Mon May  2 12:50:23 2011
New Revision: 1098542

URL: http://svn.apache.org/viewvc?rev=1098542&view=rev
Log:
Following up on r1088958, make it more obvious that we should parse the paths
before obtaining the lock. (SQLite already handled it this way; but this
certainly improves code clarity)

Suggested by: gstein

* subversion/libsvn_wc/wc_db.c
  (op_copy_baton): Remove db and dst_abspath.
  (op_copy_txn): Remove the path parsing, but still check if we need another
    lock.
  (svn_wc__db_op_copy): Parse the dst path.

Modified:
    subversion/trunk/subversion/libsvn_wc/wc_db.c

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1098542&r1=1098541&r2=1098542&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Mon May  2 12:50:23 2011
@@ -2751,8 +2751,6 @@ struct op_copy_baton
   svn_wc__db_wcroot_t *src_wcroot;
   const char *src_relpath;
 
-  svn_wc__db_t *db;
-  const char *dst_abspath;
   svn_wc__db_wcroot_t *dst_wcroot;
   const char *dst_relpath;
 
@@ -2766,26 +2764,14 @@ op_copy_txn(void * baton, svn_sqlite__db
 {
   struct op_copy_baton *ocb = baton;
 
-  if (ocb->dst_wcroot == NULL)
+  if (sdb != ocb->dst_wcroot->sdb)
     {
-       SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&ocb->dst_wcroot,
-                                                     &ocb->dst_relpath,
-                                                     ocb->db,
-                                                     ocb->dst_abspath,
-                                                     scratch_pool,
-                                                     scratch_pool));
-
-       VERIFY_USABLE_WCROOT(ocb->dst_wcroot);
+       /* Source and destination databases differ; so also start a lock
+          in the destination database, by calling ourself in a lock. */
 
-       if (ocb->dst_wcroot->sdb != sdb)
-         {
-            /* Source and destination databases differ; so also start a lock
-               in the destination database, by calling ourself in a lock. */
-
-            return svn_error_return(
+      return svn_error_return(
                         svn_sqlite__with_lock(ocb->dst_wcroot->sdb,
                                               op_copy_txn, ocb, scratch_pool));
-         }
     }
 
   /* From this point we can assume a lock in the src and dst databases */
@@ -2816,10 +2802,16 @@ svn_wc__db_op_copy(svn_wc__db_t *db,
                                                 scratch_pool, scratch_pool));
   VERIFY_USABLE_WCROOT(ocb.src_wcroot);
 
-  ocb.db = db;
-  ocb.dst_abspath = dst_abspath;
+  SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&ocb.dst_wcroot,
+                                                &ocb.dst_relpath,
+                                                db, dst_abspath,
+                                                scratch_pool, scratch_pool));
+  VERIFY_USABLE_WCROOT(ocb.dst_wcroot);
+
   ocb.work_items = work_items;
 
+  /* Call with the sdb in src_wcroot. It might call itself again to
+     also obtain a lock in dst_wcroot */
   SVN_ERR(svn_sqlite__with_lock(ocb.src_wcroot->sdb, op_copy_txn, &ocb,
                                 scratch_pool));