subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1132442 - in /subversion/trunk/subversion: include/svn_wc.h libsvn_client/deprecated.c libsvn_wc/info.c svn/info-cmd.c
Date Sun, 05 Jun 2011 16:11:52 GMT
Author: rhuijben
Date: Sun Jun  5 16:11:51 2011
New Revision: 1132442

URL: http://svn.apache.org/viewvc?rev=1132442&view=rev
Log:
Reduce the typical number of database transactions for filling the svn_wc_info_t
structure to 1 by using one call to svn_wc__db_read_info() to obtain most of
the information we need in the rest of the function.

Instead of fixing all cases at once, fall back to the old code in the less
common code paths.

* subversion/include/svn_wc.h
  (svn_wc_info_t): Rename two fields to document their real purpose.

* subversion/libsvn_client/deprecated.c
  (info_from_info2): Update caller.

* subversion/libsvn_wc/info.c
  (build_info_for_entry): Start with a call to svn_wc__db_read_info and use that
    to avoid calls to several calls that would just call read_info again.

* subversion/svn/info-cmd.c
  (print_info__xml,
   print_info): Update users.

Modified:
    subversion/trunk/subversion/include/svn_wc.h
    subversion/trunk/subversion/libsvn_client/deprecated.c
    subversion/trunk/subversion/libsvn_wc/info.c
    subversion/trunk/subversion/svn/info-cmd.c

Modified: subversion/trunk/subversion/include/svn_wc.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_wc.h?rev=1132442&r1=1132441&r2=1132442&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_wc.h (original)
+++ subversion/trunk/subversion/include/svn_wc.h Sun Jun  5 16:11:51 2011
@@ -3014,7 +3014,6 @@ typedef struct svn_wc_info_t
   svn_wc_schedule_t schedule;
   const char *copyfrom_url;
   svn_revnum_t copyfrom_rev;
-  apr_time_t text_time;
   const svn_checksum_t *checksum;
   const char *changelist;
   svn_depth_t depth;
@@ -3024,7 +3023,12 @@ typedef struct svn_wc_info_t
    * representation, or #SVN_INVALID_FILESIZE if unknown.
    * Not applicable for directories.
    */
-  svn_filesize_t working_size;
+  svn_filesize_t recorded_size;
+
+  /**
+   * The time at which the file had the recorded size recorded_size and was
+   * considered unmodified. */
+  apr_time_t recorded_time;
 
   /** Array of const svn_wc_conflict_description2_t * which contains info
    * on any conflict of which this node is a victim. Otherwise NULL.  */

Modified: subversion/trunk/subversion/libsvn_client/deprecated.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/deprecated.c?rev=1132442&r1=1132441&r2=1132442&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/deprecated.c (original)
+++ subversion/trunk/subversion/libsvn_client/deprecated.c Sun Jun  5 16:11:51 2011
@@ -2122,7 +2122,7 @@ info_from_info2(svn_info_t **new_info,
       info->schedule            = info2->wc_info->schedule;
       info->copyfrom_url        = info2->wc_info->copyfrom_url;
       info->copyfrom_rev        = info2->wc_info->copyfrom_rev;
-      info->text_time           = info2->wc_info->text_time;
+      info->text_time           = info2->wc_info->recorded_time;
       info->prop_time           = 0;
       if (info2->wc_info->checksum
             && info2->wc_info->checksum->kind == svn_checksum_md5)
@@ -2133,7 +2133,7 @@ info_from_info2(svn_info_t **new_info,
       info->changelist          = info2->wc_info->changelist;
       info->depth               = info2->wc_info->depth;
 
-      info->working_size64      = info2->wc_info->working_size;
+      info->working_size64      = info2->wc_info->recorded_size;
       if (((apr_size_t)info->working_size64) == info->working_size64)
         info->working_size       = (apr_size_t)info->working_size64;
       else /* >= 4GB */

Modified: subversion/trunk/subversion/libsvn_wc/info.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/info.c?rev=1132442&r1=1132441&r2=1132442&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/info.c (original)
+++ subversion/trunk/subversion/libsvn_wc/info.c Sun Jun  5 16:11:51 2011
@@ -45,191 +45,211 @@ build_info_for_entry(svn_info2_t **info,
                      apr_pool_t *scratch_pool)
 {
   svn_info2_t *tmpinfo;
-  svn_boolean_t is_copy_target;
-  svn_boolean_t exclude = FALSE;
-  svn_boolean_t is_copy;
-  svn_revnum_t rev;
   const char *repos_relpath;
-
-  if (kind == svn_node_none)
-    {
-      svn_wc__db_status_t status;
-      svn_error_t *err = svn_wc__db_read_info(&status, NULL, NULL, NULL, NULL,
-                                              NULL, NULL, NULL, NULL, NULL,
-                                              NULL, NULL, NULL, NULL, NULL,
-                                              NULL, NULL, NULL, NULL, NULL,
-                                              NULL, NULL, NULL, NULL, NULL,
-                                              NULL, NULL,
-                                              db, local_abspath,
-                                              scratch_pool, scratch_pool);
-
-      if ((! err) && (status == svn_wc__db_status_excluded))
-        exclude = TRUE;
-
-      svn_error_clear(err);
-      if (! exclude)
-        return svn_error_createf(SVN_ERR_WC_PATH_NOT_FOUND, NULL,
-                                 _("The node '%s' was not found."),
-                                 svn_dirent_local_style(local_abspath,
-                                                        scratch_pool));
-    }
+  svn_wc__db_status_t status;
+  svn_wc__db_kind_t db_kind;
+  const char *original_repos_relpath;
+  const char *original_repos_root_url;
+  const char *original_uuid;
+  svn_revnum_t original_revision;
+  svn_wc__db_lock_t *lock;
+  svn_boolean_t conflicted;
+  svn_boolean_t op_root;
+  svn_boolean_t have_base;
+  svn_wc_info_t *wc_info;
 
   tmpinfo = apr_pcalloc(result_pool, sizeof(*tmpinfo));
   tmpinfo->kind = kind;
 
-  tmpinfo->wc_info = apr_pcalloc(result_pool, sizeof(*tmpinfo->wc_info));
+  wc_info = apr_pcalloc(result_pool, sizeof(*wc_info));
+  tmpinfo->wc_info = wc_info;
 
-  SVN_ERR(svn_wc__internal_get_origin(&is_copy, &rev, &repos_relpath,
-                                      &tmpinfo->repos_root_URL,
-                                      &tmpinfo->repos_UUID,
-                                      db, local_abspath, TRUE,
-                                      result_pool, scratch_pool));
+  wc_info->copyfrom_rev = SVN_INVALID_REVNUM;
 
-  /* If we didn't get an origin, get it directly */
-  if (!tmpinfo->repos_root_URL)
-    {
-      SVN_ERR(svn_wc__internal_get_repos_info(&tmpinfo->repos_root_URL,
-                                              &tmpinfo->repos_UUID,
-                                              db, local_abspath,
-                                              result_pool, scratch_pool));
-    }
+  SVN_ERR(svn_wc__db_read_info(&status, &db_kind, &tmpinfo->rev,
+                               &repos_relpath,
+                               &tmpinfo->repos_root_URL, &tmpinfo->repos_UUID,
+                               &tmpinfo->last_changed_rev,
+                               &tmpinfo->last_changed_date,
+                               &tmpinfo->last_changed_author,
+                               &wc_info->depth, &wc_info->checksum, NULL,
+                               &original_repos_relpath,
+                               &original_repos_root_url, &original_uuid,
+                               &original_revision, &lock,
+                               &wc_info->recorded_size,
+                               &wc_info->recorded_time,
+                               &wc_info->changelist,
+                               &conflicted, &op_root, NULL, NULL, 
+                               &have_base, NULL, NULL,
+                               db, local_abspath,
+                               result_pool, scratch_pool));
 
-  if (repos_relpath)
+  if (original_repos_root_url != NULL)
     {
-      SVN_ERR(svn_wc__db_read_info(NULL, NULL, NULL, NULL, NULL, NULL,
-                                   &tmpinfo->last_changed_rev,
-                                   &tmpinfo->last_changed_date,
-                                   &tmpinfo->last_changed_author,
-                                   NULL, NULL, NULL, NULL, NULL, NULL,
-                                   NULL, NULL, NULL, NULL, NULL, NULL,
-                                   NULL, NULL, NULL, NULL, NULL, NULL,
-                                   db, local_abspath, result_pool,
-                                   scratch_pool));
+      tmpinfo->repos_root_URL = original_repos_root_url;
+      tmpinfo->repos_UUID = original_uuid;
     }
-  else
-    tmpinfo->last_changed_rev = SVN_INVALID_REVNUM;
-
-  if (is_copy)
-    SVN_ERR(svn_wc__internal_get_commit_base_rev(&tmpinfo->rev, db,
-                                                 local_abspath, scratch_pool));
-  else
-    tmpinfo->rev = rev;
-
-  /* ### We should also just be fetching the true BASE revision
-     ### above, which means copied items would also not have a
-     ### revision to display.  But WC-1 wants to show the revision of
-     ### copy targets as the copyfrom-rev.  *sigh*
-  */
-  tmpinfo->wc_info->copyfrom_rev = SVN_INVALID_REVNUM;
 
-  if (is_copy)
+  if (status == svn_wc__db_status_added)
     {
-      SVN_ERR(svn_wc__internal_get_copyfrom_info(NULL, NULL, NULL, NULL,
-                                                 &is_copy_target,
-                                                 db, local_abspath,
-                                                 scratch_pool, scratch_pool));
+      /* ### We should also just be fetching the true BASE revision
+         ### here, which means copied items would also not have a
+         ### revision to display.  But WC-1 wants to show the revision of
+         ### copy targets as the copyfrom-rev.  *sigh* */
+
+      if (original_repos_relpath)
+        {
+          /* Root or child of copy */
+          tmpinfo->rev = original_revision;
+          repos_relpath = original_repos_relpath;
+
+          if (op_root)
+            {
+              wc_info->copyfrom_url =
+                    svn_path_url_add_component2(tmpinfo->repos_root_URL,
+                                                original_repos_relpath,
+                                                result_pool);
 
-      if (is_copy_target)
+              wc_info->copyfrom_rev = original_revision;
+            }
+        }
+      else if (op_root)
         {
-          tmpinfo->wc_info->copyfrom_url = svn_path_url_add_component2(
-                                               tmpinfo->repos_root_URL,
-                                               repos_relpath, result_pool);
-          tmpinfo->wc_info->copyfrom_rev = rev;
+          /* Local addition */
+          SVN_ERR(svn_wc__db_scan_addition(NULL, NULL, &repos_relpath,
+                                           &tmpinfo->repos_root_URL,
+                                           &tmpinfo->repos_UUID,
+                                           NULL, NULL, NULL, NULL,
+                                           db, local_abspath,
+                                           result_pool, scratch_pool));
+
+          if (have_base)
+            SVN_ERR(svn_wc__db_base_get_info(NULL, NULL, &tmpinfo->rev, NULL,
+                                             NULL, NULL, NULL, NULL, NULL,
+                                             NULL, NULL, NULL, NULL, NULL,
+                                             NULL, NULL,
+                                             db, local_abspath,
+                                             scratch_pool, scratch_pool));
         }
+      else
+        {
+          /* Child of copy. ### Not WC-NG like */
+          SVN_ERR(svn_wc__internal_get_origin(NULL, &tmpinfo->rev,
+                                              &repos_relpath,
+                                              &tmpinfo->repos_root_URL,
+                                              &tmpinfo->repos_UUID,
+                                              db, local_abspath, TRUE,
+                                              result_pool, scratch_pool));
+        }
+
+      /* ### We should be able to avoid both these calls with the information
+         from read_info() in most cases */
+      SVN_ERR(svn_wc__internal_node_get_schedule(&wc_info->schedule, NULL,
+                                                 db, local_abspath,
+                                                 scratch_pool));
+      SVN_ERR(svn_wc__db_read_url(&tmpinfo->URL, db, local_abspath,
+                                result_pool, scratch_pool));
     }
-  else if (repos_relpath)
-    tmpinfo->URL = svn_path_url_add_component2(tmpinfo->repos_root_URL,
-                                               repos_relpath,
-                                               result_pool);
-
-  /* Don't create a URL for local additions */
-  if (!tmpinfo->URL)
-    SVN_ERR(svn_wc__db_read_url(&tmpinfo->URL, db, local_abspath,
+  else if (status == svn_wc__db_status_deleted)
+    {
+      SVN_ERR(svn_wc__db_read_pristine_info(NULL, NULL,
+                                            &tmpinfo->last_changed_rev,
+                                            &tmpinfo->last_changed_date,
+                                            &tmpinfo->last_changed_author,
+                                            &wc_info->depth,
+                                            &wc_info->checksum,
+                                            NULL, NULL,
+                                            db, local_abspath,
+                                            result_pool, scratch_pool));
+
+      SVN_ERR(svn_wc__internal_get_repos_info(&tmpinfo->repos_root_URL,
+                                              &tmpinfo->repos_UUID,
+                                              db, local_abspath,
+                                              result_pool, scratch_pool));
+
+      SVN_ERR(svn_wc__db_read_url(&tmpinfo->URL, db, local_abspath,
                                 result_pool, scratch_pool));
 
-  if (tmpinfo->kind == svn_node_file)
-    {
-      SVN_ERR(svn_wc__db_read_info(NULL, NULL, NULL, NULL, NULL, NULL,
-                                   NULL, NULL, NULL, NULL,
-                                   &tmpinfo->wc_info->checksum, NULL,
-                                   NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                                   &tmpinfo->wc_info->changelist,
-                                   NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                                   db, local_abspath, result_pool,
-                                   scratch_pool));
+      /* And now fetch the revision of what will be deleted */
+      {
+        const char *work_del_abspath;
+
+        SVN_ERR(svn_wc__db_scan_deletion(NULL, NULL,
+                                         &work_del_abspath,
+                                         db, local_abspath,
+                                         scratch_pool, scratch_pool));
+        if (work_del_abspath != NULL)
+          {
+            /* This is a deletion within a copied subtree. Get the copied-from
+             * revision. */
+            SVN_ERR(svn_wc__db_scan_addition(NULL, NULL, NULL, NULL, NULL,
+                                             NULL, NULL, NULL,
+                                             &tmpinfo->rev,
+                                             db,
+                                             svn_dirent_dirname(
+                                                  work_del_abspath,
+                                                  scratch_pool),
+                                             result_pool, scratch_pool));
+          }
+        else
+          SVN_ERR(svn_wc__db_base_get_info(NULL, NULL, &tmpinfo->rev,
+                                           NULL, NULL, NULL, NULL, NULL, NULL,
+                                           NULL, NULL, NULL, NULL, NULL, NULL,
+                                           NULL,
+                                           db, local_abspath,
+                                           result_pool, scratch_pool));
+      }
+      wc_info->schedule = svn_wc_schedule_delete;
     }
-
-  if (tmpinfo->kind == svn_node_dir)
+  else if (status == svn_wc__db_status_not_present
+           || status == svn_wc__db_status_absent)
     {
-      SVN_ERR(svn_wc__db_read_info(NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                                   NULL, NULL, &tmpinfo->wc_info->depth,
-                                   NULL, NULL, NULL, NULL, NULL, NULL,
-                                   NULL, NULL, NULL, NULL, NULL, NULL,
-                                   NULL, NULL, NULL, NULL, NULL,
-                                   db, local_abspath, scratch_pool,
-                                   scratch_pool));
-
-      if (tmpinfo->wc_info->depth == svn_depth_unknown)
-        tmpinfo->wc_info->depth = svn_depth_infinity;
+      return svn_error_createf(SVN_ERR_WC_PATH_NOT_FOUND, NULL,
+                               _("The node '%s' was not found."),
+                               svn_dirent_local_style(local_abspath,
+                                                      scratch_pool));
     }
   else
-    tmpinfo->wc_info->depth = svn_depth_infinity;
+    {
+      /* Just a BASE node. We have all the info we need */
+      tmpinfo->URL = svn_path_url_add_component2(tmpinfo->repos_root_URL,
+                                                 repos_relpath,
+                                                 result_pool);
+      wc_info->schedule = svn_wc_schedule_normal;
+    }
 
-  if (exclude)
+  if (status == svn_wc__db_status_excluded)
     tmpinfo->wc_info->depth = svn_depth_exclude;
 
   /* A default */
   tmpinfo->size = SVN_INVALID_FILESIZE;
 
-  SVN_ERR(svn_wc__internal_node_get_schedule(&tmpinfo->wc_info->schedule, NULL,
-                                             db, local_abspath,
-                                             scratch_pool));
-
   SVN_ERR(svn_wc__db_get_wcroot(&tmpinfo->wc_info->wcroot_abspath, db,
                                 local_abspath, result_pool, scratch_pool));
 
-  SVN_ERR(svn_wc__db_read_info(NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                               NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                               NULL, NULL, NULL,
-                               &tmpinfo->wc_info->working_size,
-                               &tmpinfo->wc_info->text_time,
-                               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                               db, local_abspath,
-                               scratch_pool, scratch_pool));
-
-  SVN_ERR(svn_wc__db_read_conflicts(&tmpinfo->wc_info->conflicts, db,
-                                    local_abspath, result_pool, scratch_pool));
+  if (conflicted)
+    SVN_ERR(svn_wc__db_read_conflicts(&wc_info->conflicts, db,
+                                      local_abspath,
+                                      result_pool, scratch_pool));
+  else
+    wc_info->conflicts = NULL;
 
   /* lock stuff */
-  if (kind == svn_node_file)
+  if (lock != NULL)
     {
-      svn_wc__db_lock_t *lock;
-
-      svn_error_t *err = svn_wc__db_base_get_info(NULL, NULL, NULL, NULL,
-                                                  NULL, NULL, NULL, NULL,
-                                                  NULL, NULL, NULL, NULL,
-                                                  &lock, NULL, NULL, NULL,
-                                                  db, local_abspath,
-                                                  result_pool, scratch_pool);
-
-      if (err && (err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND))
-        {
-          svn_error_clear(err);
-          lock = NULL;
-        }
-      else if (err)
-        return svn_error_return(err);
-
-      if (lock)
-        {
-          tmpinfo->lock = apr_pcalloc(result_pool, sizeof(*(tmpinfo->lock)));
-          tmpinfo->lock->token         = lock->token;
-          tmpinfo->lock->owner         = lock->owner;
-          tmpinfo->lock->comment       = lock->comment;
-          tmpinfo->lock->creation_date = lock->date;
-        }
+      tmpinfo->lock = apr_pcalloc(result_pool, sizeof(*(tmpinfo->lock)));
+      tmpinfo->lock->token         = lock->token;
+      tmpinfo->lock->owner         = lock->owner;
+      tmpinfo->lock->comment       = lock->comment;
+      tmpinfo->lock->creation_date = lock->date;
     }
 
+  /* ### Temporary hacks to keep our test suite happy: */
+  if (db_kind == svn_wc__db_kind_dir)
+    wc_info->changelist = NULL; /* Should be valid in the DB */
+  if (db_kind != svn_wc__db_kind_dir)
+    wc_info->depth = svn_depth_infinity; /* Should be unknown */
+
   *info = tmpinfo;
   return SVN_NO_ERROR;
 }

Modified: subversion/trunk/subversion/svn/info-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/info-cmd.c?rev=1132442&r1=1132441&r2=1132442&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/info-cmd.c (original)
+++ subversion/trunk/subversion/svn/info-cmd.c Sun Jun  5 16:11:51 2011
@@ -150,10 +150,11 @@ print_info_xml(void *baton,
                                               info->wc_info->copyfrom_rev));
 
       /* "<text-updated> xx </text-updated>" */
-      if (info->wc_info->text_time)
+      if (info->wc_info->recorded_time)
         svn_cl__xml_tagged_cdata(&sb, pool, "text-updated",
-                                 svn_time_to_cstring(info->wc_info->text_time,
-                                                     pool));
+                                 svn_time_to_cstring(
+                                          info->wc_info->recorded_time,
+                                          pool));
 
       /* "<checksum> xx </checksum>" */
       /* ### Print the checksum kind. */
@@ -413,8 +414,8 @@ print_info(void *baton,
 
   if (info->wc_info)
     {
-      if (info->wc_info->text_time)
-        SVN_ERR(svn_cl__info_print_time(info->wc_info->text_time,
+      if (info->wc_info->recorded_time)
+        SVN_ERR(svn_cl__info_print_time(info->wc_info->recorded_time,
                                         _("Text Last Updated"), pool));
 
       if (info->wc_info->checksum)



Mime
View raw message