You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2010/11/30 09:59:37 UTC

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

Author: julianfoad
Date: Tue Nov 30 08:59:36 2010
New Revision: 1040438

URL: http://svn.apache.org/viewvc?rev=1040438&view=rev
Log:
Simplify use of fetch_repos_info().  The immediate effect is marginal; the
benefit will come when a forthcoming patch makes more use of the function.

* subversion/libsvn_wc/wc_db.c
  (fetch_repos_info): Accept a null input, and exit quickly if no outputs
    are wanted, so the caller does not have to check those things.
  (svn_wc__db_scan_base_repos, svn_wc__db_scan_addition): Simplify by
    omitting those checks.
  (svn_wc__db_read_children_info): Remove an unused variable. This doesn't
    depend on the above change.

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=1040438&r1=1040437&r2=1040438&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Tue Nov 30 08:59:36 2010
@@ -495,7 +495,8 @@ get_pristine_fname(const char **pristine
 
 
 /* Look up REPOS_ID in SDB and set *REPOS_ROOT_URL and/or *REPOS_UUID to
- * its root URL and UUID respectively.  Either output parameter may be
+ * its root URL and UUID respectively.  If REPOS_ID is INVALID_REPOS_ID,
+ * use NULL for both URL and UUID.  Either or both output parameters may be
  * NULL if not wanted. */
 static svn_error_t *
 fetch_repos_info(const char **repos_root_url,
@@ -507,6 +508,18 @@ fetch_repos_info(const char **repos_root
   svn_sqlite__stmt_t *stmt;
   svn_boolean_t have_row;
 
+  if (!repos_root_url && !repos_uuid)
+    return SVN_NO_ERROR;
+
+  if (repos_id == INVALID_REPOS_ID)
+    {
+      if (repos_root_url)
+        *repos_root_url = NULL;
+      if (repos_uuid)
+        *repos_uuid = NULL;
+      return SVN_NO_ERROR;
+    }
+
   SVN_ERR(svn_sqlite__get_statement(&stmt, sdb,
                                     STMT_SELECT_REPOSITORY_BY_ID));
   SVN_ERR(svn_sqlite__bindf(stmt, "i", repos_id));
@@ -5388,11 +5401,10 @@ svn_wc__db_read_children_info(apr_hash_t
             }
           else
             {
-              const char *repos_uuid;
               apr_int64_t repos_id = svn_sqlite__column_int64(stmt, 1);
               if (!repos_root_url)
                 {
-                  err = fetch_repos_info(&repos_root_url, &repos_uuid,
+                  err = fetch_repos_info(&repos_root_url, NULL,
                                          pdh->wcroot->sdb, repos_id,
                                          result_pool);
                   if (err)
@@ -6508,10 +6520,8 @@ svn_wc__db_scan_base_repos(const char **
   SVN_ERR(scan_upwards_for_repos(&repos_id, repos_relpath,
                                  pdh->wcroot, local_relpath,
                                  result_pool, scratch_pool));
-
-  if (repos_root_url || repos_uuid)
-    return fetch_repos_info(repos_root_url, repos_uuid, pdh->wcroot->sdb,
-                            repos_id, result_pool);
+  SVN_ERR(fetch_repos_info(repos_root_url, repos_uuid, pdh->wcroot->sdb,
+                           repos_id, result_pool));
 
   return SVN_NO_ERROR;
 }
@@ -6928,26 +6938,13 @@ svn_wc__db_scan_addition(svn_wc__db_stat
   if (op_root_abspath)
     *op_root_abspath = svn_dirent_join(pdh->wcroot->abspath, op_root_relpath,
                                        result_pool);
-  if (repos_id_p)
-    {
-      SVN_ERR_ASSERT(repos_id != INVALID_REPOS_ID);
-      SVN_ERR(fetch_repos_info(repos_root_url, repos_uuid, pdh->wcroot->sdb,
-                               repos_id, result_pool));
-    }
-  if (original_repos_id_p)
-    {
-      if (original_repos_id == INVALID_REPOS_ID)
-        {
-          if (original_root_url)
-            *original_root_url = NULL;
-          if (original_uuid)
-            *original_uuid = NULL;
-        }
-      else
-        SVN_ERR(fetch_repos_info(original_root_url, original_uuid,
-                                 pdh->wcroot->sdb, original_repos_id,
-                                 result_pool));
-    }
+  /* REPOS_ID must be valid if requested; ORIGINAL_REPOS_ID need not be. */
+  SVN_ERR_ASSERT(repos_id_p == NULL || repos_id != INVALID_REPOS_ID);
+  SVN_ERR(fetch_repos_info(repos_root_url, repos_uuid, pdh->wcroot->sdb,
+                           repos_id, result_pool));
+  SVN_ERR(fetch_repos_info(original_root_url, original_uuid,
+                           pdh->wcroot->sdb, original_repos_id,
+                           result_pool));
 
   return SVN_NO_ERROR;
 }