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/24 01:39:36 UTC

svn commit: r1096258 - in /subversion/trunk/subversion: include/svn_wc.h libsvn_wc/diff.c

Author: rhuijben
Date: Sat Apr 23 23:39:36 2011
New Revision: 1096258

URL: http://svn.apache.org/viewvc?rev=1096258&view=rev
Log:
Following up on r1096057 and r1096068, move two more support functions in the
wc diff editor to using only the editor baton and passed paths.

* subversion/include/svn_wc.h
  (svn_wc_get_diff_editor6): Update description of use_text_base, to remove
    a few invalid assumptions I added. The definition is back in line with the
    <=1.6 definition now.

* subversion/libsvn_wc/diff.c
  (walk_local_nodes_diff): Use svn_wc__db_read_info() instead of two db calls.
  (report_wc_file_as_added,
   report_wc_directory_as_added): Update arguments to edit_baton and paths.
     Update callers.
  (delete_entry): Update caller.
  (close_file): Initialize some variables when ignoring an error.

Modified:
    subversion/trunk/subversion/include/svn_wc.h
    subversion/trunk/subversion/libsvn_wc/diff.c

Modified: subversion/trunk/subversion/include/svn_wc.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_wc.h?rev=1096258&r1=1096257&r2=1096258&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_wc.h (original)
+++ subversion/trunk/subversion/include/svn_wc.h Sat Apr 23 23:39:36 2011
@@ -5911,6 +5911,10 @@ svn_wc_canonicalize_svn_prop(const svn_s
  * repository. The editor is allocated in @a result_pool; temporary
  * calculations are performed in @a scratch_pool.
  *
+ * This editor supports diffing either the actual files and properties in the
+ * working copy (when @a use_text_base is #FALSE), or the current pristine
+ * information (when @a use_text_base is #TRUE) against the editor driver.
+ *
  * @a anchor_path/@a target represent the base of the hierarchy to be compared.
  *
  * @a callbacks/@a callback_baton is the callback table to use when two
@@ -5936,10 +5940,6 @@ svn_wc_canonicalize_svn_prop(const svn_s
  * if they weren't modified after being copied. This allows the callbacks
  * to generate appropriate --git diff headers for such files.
  *
- * If @a use_text_base is TRUE, then compare the repository against
- * the working copy's original checkout files (aka BASE), rather than
- * the working files.
- *
  * Normally, the difference from repository->working_copy is shown.
  * If @a reverse_order is TRUE, then show working_copy->repository diffs.
  *

Modified: subversion/trunk/subversion/libsvn_wc/diff.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/diff.c?rev=1096258&r1=1096257&r2=1096258&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/diff.c (original)
+++ subversion/trunk/subversion/libsvn_wc/diff.c Sat Apr 23 23:39:36 2011
@@ -873,7 +873,7 @@ walk_local_nodes_diff(struct edit_baton 
     {
       const char *name = APR_ARRAY_IDX(children, i, const char*);
       const char *child_abspath, *child_path;
-      svn_boolean_t hidden;
+      svn_wc__db_status_t status;
       svn_wc__db_kind_t kind;
 
       svn_pool_clear(iterpool);
@@ -881,13 +881,6 @@ walk_local_nodes_diff(struct edit_baton 
       if (eb->cancel_func)
         SVN_ERR(eb->cancel_func(eb->cancel_baton));
 
-      child_abspath = svn_dirent_join(local_abspath, name, iterpool);
-
-      SVN_ERR(svn_wc__db_node_hidden(&hidden, db, child_abspath, iterpool));
-
-      if (hidden)
-        continue;
-
       /* In the anchor directory, if the anchor is not the target then all
          entries other than the target should not be diff'd. Running diff
          on one file in a directory should not diff other files in that
@@ -895,14 +888,27 @@ walk_local_nodes_diff(struct edit_baton 
       if (in_anchor_not_target && strcmp(eb->target, name))
         continue;
 
+
+      child_abspath = svn_dirent_join(local_abspath, name, iterpool);
+
+      SVN_ERR(svn_wc__db_read_info(&status, &kind, 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, child_abspath,
+                                   iterpool, iterpool));
+
+      if (status == svn_wc__db_status_not_present
+          || status == svn_wc__db_status_excluded
+          || status == svn_wc__db_status_absent)
+        continue;
+
       child_path = svn_dirent_join(path, name, iterpool);
 
       /* Skip this node if it is in the list of nodes already diff'd. */
       if (compared && apr_hash_get(compared, child_path, APR_HASH_KEY_STRING))
         continue;
 
-      SVN_ERR(svn_wc__db_read_kind(&kind, db, child_abspath, TRUE,
-                                   iterpool));
       switch (kind)
         {
         case svn_wc__db_kind_file:
@@ -957,11 +963,12 @@ walk_local_nodes_diff(struct edit_baton 
  * Do all allocation in POOL.
  */
 static svn_error_t *
-report_wc_file_as_added(struct dir_baton *db,
+report_wc_file_as_added(struct edit_baton *eb,
+                        const char *local_abspath,
                         const char *path,
-                        apr_pool_t *pool)
+                        apr_pool_t *scratch_pool)
 {
-  struct edit_baton *eb = db->eb;
+  svn_wc__db_t *db = eb->db;
   apr_hash_t *emptyprops;
   const char *mimetype;
   apr_hash_t *wcprops = NULL;
@@ -969,15 +976,12 @@ report_wc_file_as_added(struct dir_baton
   const char *empty_file;
   const char *source_file;
   const char *translated_file;
-  const char *local_abspath;
   svn_wc__db_status_t status;
   svn_revnum_t revision;
 
-  SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
-
   /* If this entry is filtered by changelist specification, do nothing. */
-  if (! svn_wc__internal_changelist_match(eb->db, local_abspath,
-                                          eb->changelist_hash, pool))
+  if (! svn_wc__internal_changelist_match(db, local_abspath,
+                                          eb->changelist_hash, scratch_pool))
     return SVN_NO_ERROR;
 
   SVN_ERR(get_empty_file(eb, &empty_file));
@@ -986,12 +990,13 @@ report_wc_file_as_added(struct dir_baton
                                NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                                NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                                NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                               eb->db, local_abspath, pool, pool));
+                               db, local_abspath,
+                               scratch_pool, scratch_pool));
 
   if (status == svn_wc__db_status_added)
     SVN_ERR(svn_wc__db_scan_addition(&status, NULL, NULL, NULL, NULL, NULL,
-                                     NULL, NULL, NULL, eb->db, local_abspath,
-                                     pool, pool));
+                                     NULL, NULL, NULL, db, local_abspath,
+                                     scratch_pool, scratch_pool));
 
   /* We can't show additions for files that don't exist. */
   SVN_ERR_ASSERT(status != svn_wc__db_status_deleted || eb->use_text_base);
@@ -1008,36 +1013,36 @@ report_wc_file_as_added(struct dir_baton
         return SVN_NO_ERROR;
 
       /* Otherwise show just the local modifications. */
-      return file_diff(eb, local_abspath, path, pool);
+      return file_diff(eb, local_abspath, path, scratch_pool);
     }
 
-  emptyprops = apr_hash_make(pool);
+  emptyprops = apr_hash_make(scratch_pool);
 
   if (eb->use_text_base)
-    SVN_ERR(svn_wc__get_pristine_props(&wcprops, eb->db, local_abspath,
-                                       pool, pool));
+    SVN_ERR(svn_wc__get_pristine_props(&wcprops, db, local_abspath,
+                                       scratch_pool, scratch_pool));
   else
-    SVN_ERR(svn_wc__get_actual_props(&wcprops, eb->db, local_abspath,
-                                     pool, pool));
+    SVN_ERR(svn_wc__get_actual_props(&wcprops, db, local_abspath,
+                                     scratch_pool, scratch_pool));
   mimetype = get_prop_mimetype(wcprops);
 
   SVN_ERR(svn_prop_diffs(&propchanges,
-                         wcprops, emptyprops, pool));
+                         wcprops, emptyprops, scratch_pool));
 
 
   if (eb->use_text_base)
-    SVN_ERR(get_pristine_file(&source_file, eb->db, local_abspath,
-                              TRUE, pool, pool));
+    SVN_ERR(get_pristine_file(&source_file, db, local_abspath,
+                              TRUE, scratch_pool, scratch_pool));
   else
-    source_file = path;
+    source_file = local_abspath;
 
   SVN_ERR(svn_wc__internal_translated_file(
-           &translated_file, source_file, eb->db, local_abspath,
+           &translated_file, source_file, db, local_abspath,
            SVN_WC_TRANSLATE_TO_NF | SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
            eb->cancel_func, eb->cancel_baton,
-           pool, pool));
+           scratch_pool, scratch_pool));
 
-  SVN_ERR(eb->callbacks->file_added(db->local_abspath,
+  SVN_ERR(eb->callbacks->file_added(local_abspath,
                                     NULL, NULL, NULL,
                                     path,
                                     empty_file, translated_file,
@@ -1046,7 +1051,7 @@ report_wc_file_as_added(struct dir_baton
                                     NULL, SVN_INVALID_REVNUM,
                                     propchanges, emptyprops,
                                     eb->callback_baton,
-                                    pool));
+                                    scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -1060,18 +1065,20 @@ report_wc_file_as_added(struct dir_baton
  * Do all allocation in POOL.
  */
 static svn_error_t *
-report_wc_directory_as_added(struct dir_baton *db,
-                             apr_pool_t *pool)
+report_wc_directory_as_added(struct edit_baton *eb,
+                             const char *local_abspath,
+                             const char *path,
+                             svn_depth_t depth,
+                             apr_pool_t *scratch_pool)
 {
-  struct edit_baton *eb = db->eb;
-  apr_hash_t *emptyprops = apr_hash_make(pool), *wcprops = NULL;
+  svn_wc__db_t *db = eb->db;
+  apr_hash_t *emptyprops, *wcprops = NULL;
   apr_array_header_t *propchanges;
   const apr_array_header_t *children;
   int i;
   apr_pool_t *iterpool;
-  const char *dir_abspath;
 
-  SVN_ERR(svn_dirent_get_absolute(&dir_abspath, db->path, pool));
+  emptyprops = apr_hash_make(scratch_pool);
 
   /* If this directory passes changelist filtering, get its BASE or
      WORKING properties, as appropriate, and simulate their
@@ -1079,38 +1086,37 @@ report_wc_directory_as_added(struct dir_
      ### it should be noted that we do not currently allow directories
      ### to be part of changelists, so if a changelist is provided, this
      ### check will always fail. */
-  if (svn_wc__internal_changelist_match(eb->db, dir_abspath,
-                                        eb->changelist_hash, pool))
+  if (svn_wc__internal_changelist_match(db, local_abspath,
+                                        eb->changelist_hash, scratch_pool))
     {
       if (eb->use_text_base)
-        SVN_ERR(svn_wc__get_pristine_props(&wcprops, eb->db, dir_abspath,
-                                           pool, pool));
+        SVN_ERR(svn_wc__get_pristine_props(&wcprops, db, local_abspath,
+                                           scratch_pool, scratch_pool));
       else
-        SVN_ERR(svn_wc__get_actual_props(&wcprops, eb->db, dir_abspath,
-                                         pool, pool));
+        SVN_ERR(svn_wc__get_actual_props(&wcprops, db, local_abspath,
+                                         scratch_pool, scratch_pool));
 
-      SVN_ERR(svn_prop_diffs(&propchanges, wcprops, emptyprops, pool));
+      SVN_ERR(svn_prop_diffs(&propchanges, wcprops, emptyprops, scratch_pool));
 
       if (propchanges->nelts > 0)
-        SVN_ERR(eb->callbacks->dir_props_changed(db->local_abspath,
+        SVN_ERR(eb->callbacks->dir_props_changed(local_abspath,
                                                  NULL, NULL,
-                                                 db->path,
+                                                 path,
                                                  propchanges, emptyprops,
                                                  eb->callback_baton,
-                                                 pool));
+                                                 scratch_pool));
     }
 
   /* Report the addition of the directory's contents. */
-  iterpool = svn_pool_create(pool);
+  iterpool = svn_pool_create(scratch_pool);
 
-  SVN_ERR(svn_wc__db_read_children(&children, eb->db, dir_abspath,
-                                   pool, iterpool));
+  SVN_ERR(svn_wc__db_read_children(&children, db, local_abspath,
+                                   scratch_pool, iterpool));
 
   for (i = 0; i < children->nelts; i++)
     {
       const char *name = APR_ARRAY_IDX(children, i, const char *);
-      const char *child_abspath, *path;
-      svn_boolean_t hidden;
+      const char *child_abspath, *child_path;
       svn_wc__db_status_t status;
       svn_wc__db_kind_t kind;
 
@@ -1119,48 +1125,49 @@ report_wc_directory_as_added(struct dir_
       if (eb->cancel_func)
         SVN_ERR(eb->cancel_func(eb->cancel_baton));
 
-      child_abspath = svn_dirent_join(dir_abspath, name, iterpool);
-
-      SVN_ERR(svn_wc__db_node_hidden(&hidden, eb->db, child_abspath,
-                                     iterpool));
-
-      if (hidden)
-        continue;
+      child_abspath = svn_dirent_join(local_abspath, name, iterpool);
 
       SVN_ERR(svn_wc__db_read_info(&status, &kind, 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,
-                                   eb->db, child_abspath, iterpool, iterpool));
+                                   db, child_abspath, iterpool, iterpool));
+
+      if (status == svn_wc__db_status_not_present
+          || status == svn_wc__db_status_excluded
+          || status == svn_wc__db_status_absent)
+        {
+          continue;
+        }
 
       /* If comparing against WORKING, skip entries that are
          schedule-deleted - they don't really exist. */
       if (!eb->use_text_base && status == svn_wc__db_status_deleted)
         continue;
 
-      path = svn_dirent_join(db->path, name, iterpool);
+      child_path = svn_dirent_join(path, name, iterpool);
 
       switch (kind)
         {
         case svn_wc__db_kind_file:
         case svn_wc__db_kind_symlink:
-          SVN_ERR(report_wc_file_as_added(db, path, iterpool));
+          SVN_ERR(report_wc_file_as_added(eb, child_abspath, child_path,
+                                          iterpool));
           break;
 
         case svn_wc__db_kind_dir:
-          if (db->depth > svn_depth_files || db->depth == svn_depth_unknown)
+          if (depth > svn_depth_files || depth == svn_depth_unknown)
             {
-              svn_depth_t depth_below_here = db->depth;
-              struct dir_baton *subdir_baton;
+              svn_depth_t depth_below_here = depth;
 
               if (depth_below_here == svn_depth_immediates)
                 depth_below_here = svn_depth_empty;
 
-              subdir_baton = make_dir_baton(path, db, eb, FALSE,
-                                            depth_below_here,
-                                            iterpool);
-
-              SVN_ERR(report_wc_directory_as_added(subdir_baton, iterpool));
+              SVN_ERR(report_wc_directory_as_added(eb,
+                                                   child_abspath,
+                                                   child_path,
+                                                   depth_below_here,
+                                                   iterpool));
             }
           break;
 
@@ -1213,7 +1220,7 @@ delete_entry(const char *path,
 {
   struct dir_baton *pb = parent_baton;
   struct edit_baton *eb = pb->eb;
-  struct dir_baton *db;
+  svn_wc__db_t *db = eb->db;
   const char *empty_file;
   const char *full_path = svn_dirent_join(eb->anchor_path, path,
                                           pb->pool);
@@ -1229,7 +1236,7 @@ delete_entry(const char *path,
                                NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                                NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                                NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                               eb->db, local_abspath, pool, pool));
+                               db, local_abspath, pool, pool));
 
   /* If comparing against WORKING, skip nodes that are deleted
      - they don't really exist. */
@@ -1255,7 +1262,7 @@ delete_entry(const char *path,
           apr_hash_t *baseprops = NULL;
           const char *base_mimetype;
 
-          SVN_ERR(get_pristine_file(&textbase, eb->db, local_abspath,
+          SVN_ERR(get_pristine_file(&textbase, db, local_abspath,
                                     eb->use_text_base, pool, pool));
 
           SVN_ERR(svn_wc__get_pristine_props(&baseprops, eb->db, local_abspath,
@@ -1274,15 +1281,17 @@ delete_entry(const char *path,
       else
         {
           /* Or normally, show the working file being added. */
-          SVN_ERR(report_wc_file_as_added(pb, full_path, pool));
+          SVN_ERR(report_wc_file_as_added(eb, local_abspath, full_path, pool));
         }
       break;
     case svn_wc__db_kind_dir:
-      db = make_dir_baton(full_path, pb, pb->eb, FALSE,
-                          svn_depth_infinity, pool);
       /* A delete is required to change working-copy into requested
          revision, so diff should show this as an add. */
-      SVN_ERR(report_wc_directory_as_added(db, pool));
+      SVN_ERR(report_wc_directory_as_added(eb,
+                                           local_abspath,
+                                           full_path,
+                                           svn_depth_infinity,
+                                           pool));
 
     default:
       break;
@@ -1641,6 +1650,9 @@ close_file(void *file_baton,
     {
       svn_error_clear(err);
       status = svn_wc__db_status_not_present;
+      pristine_checksum = NULL;
+      had_props = FALSE;
+      props_mod = FALSE;
     }
   else
     SVN_ERR(err);