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/05/20 17:47:19 UTC

svn commit: r946676 - in /subversion/trunk/subversion/libsvn_wc: adm_files.c adm_files.h adm_ops.c diff.c update_editor.c workqueue.c

Author: julianfoad
Date: Thu May 20 15:47:19 2010
New Revision: 946676

URL: http://svn.apache.org/viewvc?rev=946676&view=rev
Log:
Replace read-only uses of svn_wc__text_base_path() and similar with new
functions that are named to indicate this usage.  The new functions simply
forward the call to the original functions, for now, but separating the
read-only uses from the writes should make it easier to migrate them to use
the WC-NG Pristine Store; at least it helps me to comprehend that process.

* subversion/libsvn_wc/adm_files.h,
  subversion/libsvn_wc/adm_files.c
  (svn_wc__text_revert_path_to_read, svn_wc__ultimate_text_base_path,
   svn_wc__ultimate_text_base_path_to_read): New functions.
  (svn_wc__get_pristine_base_contents, svn_wc__get_pristine_contents): Use
    the new functions.

* subversion/libsvn_wc/adm_ops.c
  (process_committed_leaf, svn_wc_get_pristine_copy_path): Use the new
    functions.

* subversion/libsvn_wc/diff.c
  (get_nearest_pristine_text_as_file, report_wc_file_as_added): Use the new
    functions.

* subversion/libsvn_wc/update_editor.c
  (get_pristine_base_path): Move+rename to svn_wc__ultimate_text_base_path().
  (merge_file, close_file): Use the new functions.

* subversion/libsvn_wc/workqueue.c
  (verify_pristine_present, log_do_committed): Use the new functions.

Modified:
    subversion/trunk/subversion/libsvn_wc/adm_files.c
    subversion/trunk/subversion/libsvn_wc/adm_files.h
    subversion/trunk/subversion/libsvn_wc/adm_ops.c
    subversion/trunk/subversion/libsvn_wc/diff.c
    subversion/trunk/subversion/libsvn_wc/update_editor.c
    subversion/trunk/subversion/libsvn_wc/workqueue.c

Modified: subversion/trunk/subversion/libsvn_wc/adm_files.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/adm_files.c?rev=946676&r1=946675&r2=946676&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_files.c (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_files.c Thu May 20 15:47:19 2010
@@ -281,6 +281,54 @@ svn_wc__text_base_path_to_read(const cha
 
 
 svn_error_t *
+svn_wc__text_revert_path_to_read(const char **result_abspath,
+                                 svn_wc__db_t *db,
+                                 const char *local_abspath,
+                                 apr_pool_t *result_pool)
+{
+  SVN_ERR(svn_wc__text_revert_path(result_abspath, db, local_abspath,
+                                   result_pool));
+  return SVN_NO_ERROR;
+}
+
+
+svn_error_t *
+svn_wc__ultimate_base_text_path(const char **result_abspath,
+                                svn_wc__db_t *db,
+                                const char *local_abspath,
+                                apr_pool_t *result_pool,
+                                apr_pool_t *scratch_pool)
+{
+  const svn_wc_entry_t *entry;
+  svn_boolean_t replaced;
+
+  SVN_ERR(svn_wc__get_entry(&entry, db, local_abspath, TRUE, svn_node_file,
+                            FALSE, scratch_pool, scratch_pool));
+  replaced = entry && entry->schedule == svn_wc_schedule_replace;
+
+  if (replaced)
+    SVN_ERR(svn_wc__text_revert_path(result_abspath, db, local_abspath,
+                                     result_pool));
+  else
+    SVN_ERR(svn_wc__text_base_path(result_abspath, db, local_abspath,
+                                   result_pool));
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_wc__ultimate_base_text_path_to_read(const char **result_abspath,
+                                        svn_wc__db_t *db,
+                                        const char *local_abspath,
+                                        apr_pool_t *result_pool,
+                                        apr_pool_t *scratch_pool)
+{
+  return svn_wc__ultimate_base_text_path(result_abspath, db, local_abspath,
+                                         result_pool, scratch_pool);
+}
+
+
+svn_error_t *
 svn_wc__get_pristine_base_contents(svn_stream_t **contents,
                                    svn_wc__db_t *db,
                                    const char *local_abspath,
@@ -323,8 +371,8 @@ svn_wc__get_pristine_base_contents(svn_s
   SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
 
   /* If there's a WC-1 "revert base", open that. */
-  SVN_ERR(svn_wc__text_revert_path(&revert_base, db, local_abspath,
-                                   scratch_pool));
+  SVN_ERR(svn_wc__text_revert_path_to_read(&revert_base, db, local_abspath,
+                                           scratch_pool));
   err = svn_stream_open_readonly(contents, revert_base,
                                  result_pool, scratch_pool);
   if (err)
@@ -332,8 +380,8 @@ svn_wc__get_pristine_base_contents(svn_s
       svn_error_clear(err);
 
       /* There's no "revert base", so open the "normal base". */
-      SVN_ERR(svn_wc__text_base_path(&revert_base, db, local_abspath,
-                                     scratch_pool));
+      SVN_ERR(svn_wc__text_base_path_to_read(&revert_base, db, local_abspath,
+                                             scratch_pool));
       err = svn_stream_open_readonly(contents, revert_base,
                                      result_pool, scratch_pool);
     }
@@ -412,8 +460,8 @@ svn_wc__get_pristine_contents(svn_stream
     const char *text_base;
     svn_error_t *err;
 
-    SVN_ERR(svn_wc__text_base_path(&text_base, db, local_abspath,
-                                   scratch_pool));
+    SVN_ERR(svn_wc__text_base_path_to_read(&text_base, db, local_abspath,
+                                           scratch_pool));
     SVN_ERR_ASSERT(text_base != NULL);
 
     /* ### now for some ugly hackiness. right now, file externals will
@@ -438,8 +486,8 @@ svn_wc__get_pristine_contents(svn_stream
 
         svn_error_clear(err);
 
-        SVN_ERR(svn_wc__text_revert_path(&text_base, db, local_abspath,
-                                         scratch_pool));
+        SVN_ERR(svn_wc__text_revert_path_to_read(&text_base, db, local_abspath,
+                                                 scratch_pool));
         return svn_stream_open_readonly(contents, text_base,
                                    result_pool, scratch_pool);
       }

Modified: subversion/trunk/subversion/libsvn_wc/adm_files.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/adm_files.h?rev=946676&r1=946675&r2=946676&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_files.h (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_files.h Thu May 20 15:47:19 2010
@@ -162,6 +162,36 @@ svn_wc__text_base_path_to_read(const cha
                                const char *local_abspath,
                                apr_pool_t *result_pool);
 
+/* Set *RESULT_ABSPATH to the path of the WC-1 "revert-base" text of the
+   versioned file LOCAL_ABSPATH in DB.  */
+svn_error_t *
+svn_wc__text_revert_path_to_read(const char **result_abspath,
+                                 svn_wc__db_t *db,
+                                 const char *local_abspath,
+                                 apr_pool_t *result_pool);
+
+/* Set *RESULT_ABSPATH to the path of the ultimate base text of the
+   versioned file LOCAL_ABSPATH in DB.  In WC-1 terms this means the
+   "normal text-base" or, if the node is replaced by a copy or move, the
+   "revert-base".  */
+svn_error_t *
+svn_wc__ultimate_base_text_path(const char **result_abspath,
+                                svn_wc__db_t *db,
+                                const char *local_abspath,
+                                apr_pool_t *result_pool,
+                                apr_pool_t *scratch_pool);
+
+/* Set *RESULT_ABSPATH to the path of the ultimate base text of the
+   versioned file LOCAL_ABSPATH in DB.  In WC-1 terms this means the
+   "normal text-base" or, if the node is replaced by a copy or move, the
+   "revert-base".  */
+svn_error_t *
+svn_wc__ultimate_base_text_path_to_read(const char **result_abspath,
+                                        svn_wc__db_t *db,
+                                        const char *local_abspath,
+                                        apr_pool_t *result_pool,
+                                        apr_pool_t *scratch_pool);
+
 
 
 /*** Opening all kinds of adm files ***/

Modified: subversion/trunk/subversion/libsvn_wc/adm_ops.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/adm_ops.c?rev=946676&r1=946675&r2=946676&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_ops.c (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_ops.c Thu May 20 15:47:19 2010
@@ -2289,7 +2289,8 @@ svn_wc_get_pristine_copy_path(const char
                           TRUE, TRUE, pool, pool));
   SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
 
-  SVN_ERR(svn_wc__text_base_path(pristine_path, db, local_abspath, pool));
+  SVN_ERR(svn_wc__text_base_path_to_read(pristine_path, db, local_abspath,
+                                         pool));
 
   return svn_error_return(svn_wc__db_close(db));
 }

Modified: subversion/trunk/subversion/libsvn_wc/diff.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/diff.c?rev=946676&r1=946675&r2=946676&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/diff.c (original)
+++ subversion/trunk/subversion/libsvn_wc/diff.c Thu May 20 15:47:19 2010
@@ -156,13 +156,13 @@ get_nearest_pristine_text_as_file(const 
 {
   svn_node_kind_t kind;
 
-  SVN_ERR(svn_wc__text_base_path(result_abspath, db, local_abspath,
-                                 result_pool));
+  SVN_ERR(svn_wc__text_base_path_to_read(result_abspath, db, local_abspath,
+                                         result_pool));
 
   SVN_ERR(svn_io_check_path(*result_abspath, &kind, result_pool));
   if (kind == svn_node_none)
-    SVN_ERR(svn_wc__text_revert_path(result_abspath, db, local_abspath,
-                                     result_pool));
+    SVN_ERR(svn_wc__text_revert_path_to_read(result_abspath, db, local_abspath,
+                                             result_pool));
 
   /* If there is no revert base to diff either, don't attempt to diff it.
      ### This is a band-aid.
@@ -996,7 +996,8 @@ report_wc_file_as_added(struct dir_baton
 
 
   if (eb->use_text_base)
-    SVN_ERR(svn_wc__text_base_path(&source_file, eb->db, local_abspath, pool));
+    SVN_ERR(svn_wc__text_base_path_to_read(&source_file,
+                                           eb->db, local_abspath, pool));
   else
     source_file = path;
 

Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=946676&r1=946675&r2=946676&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Thu May 20 15:47:19 2010
@@ -4017,40 +4017,6 @@ open_file(const char *path,
   return SVN_NO_ERROR;
 }
 
-/* For the given LOCAL_ABSPATH, set *OLD_TEXT_BASE_ABSPATH to the path of
-   the text-base file it should revert to: that is the (permanent)
-   text-base path, or (if the entry is replaced with history) the (permanent)
-   revert-base path.  Note: This function deals with the WC-1 concept of a
-   pair of deterministic paths for the two possible pristine texts of a node.
-
-   Allocate OLD_TEXT_BASE_ABSPATH in RESULT_POOL.  Use SCRATCH_POOL for
-   temporary allocation. */
-static svn_error_t *
-get_pristine_base_path(const char **old_text_base_abspath,
-                       svn_wc__db_t *db,
-                       const char *local_abspath,
-                       apr_pool_t *result_pool,
-                       apr_pool_t *scratch_pool)
-{
-  const svn_wc_entry_t *entry;
-  svn_boolean_t replaced;
-
-  SVN_ERR(svn_wc__get_entry(&entry, db, local_abspath, TRUE, svn_node_file,
-                            FALSE, scratch_pool, scratch_pool));
-
-  replaced = entry && entry->schedule == svn_wc_schedule_replace;
-  /* ### Should use pristine api here */
-  if (replaced)
-    SVN_ERR(svn_wc__text_revert_path(old_text_base_abspath,
-                                     db, local_abspath, result_pool));
-  else
-    SVN_ERR(svn_wc__text_base_path(old_text_base_abspath,
-                                   db, local_abspath, result_pool));
-
-  return SVN_NO_ERROR;
-}
-
-
 /* Set *MD5_CHECKSUM to the MD-5 hex digest of the BASE_NODE pristine text
  * of LOCAL_ABSPATH in DB, or to NULL if it has no BASE_NODE or if that
  * checksum is not known.  Allocate *MD5_CHECKSUM in RESULT_POOL.
@@ -4381,9 +4347,9 @@ merge_file(svn_skel_t **work_items,
       && ! entry->file_external_path)  /* ### EBUG */
     is_replaced = TRUE;
 
-  SVN_ERR(get_pristine_base_path(&text_base_abspath,
-                                 eb->db, fb->local_abspath,
-                                 fb->pool, pool));
+  SVN_ERR(svn_wc__ultimate_base_text_path(&text_base_abspath,
+                                          eb->db, fb->local_abspath,
+                                          pool, pool));
 
   /* For 'textual' merging, we implement this matrix.
 
@@ -4445,8 +4411,8 @@ merge_file(svn_skel_t **work_items,
               if (entry && entry->file_external_path)
                 {
                   SVN_ERR_ASSERT(entry->schedule == svn_wc_schedule_replace);
-                  SVN_ERR(svn_wc__text_revert_path(install_from, eb->db,
-                                                   fb->local_abspath, pool));
+                  SVN_ERR(svn_wc__text_revert_path_to_read(
+                            install_from, eb->db, fb->local_abspath, pool));
                 }
             }
         }
@@ -4611,7 +4577,7 @@ merge_file(svn_skel_t **work_items,
   if (new_text_base_tmp_abspath)
     {
       /* Move the temp text-base file to its final destination.
-       * FB->text_base_path is the appropriate path: the "revert-base" path
+       * text_base_abspath is the appropriate path: the "revert-base" path
        * if the node is replaced, else the usual text-base path. */
       SVN_ERR(svn_wc__loggy_move(&work_item, eb->db, pb->local_abspath,
                                  new_text_base_tmp_abspath,
@@ -4968,7 +4934,7 @@ close_file(void *file_baton,
 
   /* Clean up any temporary files.  */
 
-  /* For the INSTALL_FROM file, be careful that it doesn't refer to the
+  /* ### For the INSTALL_FROM file, be careful that it doesn't refer to the
      working file, or the revert text base. (sigh)  Hopefully, this will
      be cleared up in the future.  */
   if (install_from != NULL
@@ -4976,8 +4942,8 @@ close_file(void *file_baton,
     {
       const char *revert_base_abspath;
 
-      SVN_ERR(svn_wc__text_revert_path(&revert_base_abspath, eb->db,
-                                       fb->local_abspath, pool));
+      SVN_ERR(svn_wc__text_revert_path_to_read(&revert_base_abspath, eb->db,
+                                               fb->local_abspath, pool));
       if (strcmp(install_from, revert_base_abspath) != 0)
         {
           SVN_ERR(svn_wc__wq_build_file_remove(&work_item, eb->db,

Modified: subversion/trunk/subversion/libsvn_wc/workqueue.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/workqueue.c?rev=946676&r1=946675&r2=946676&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/workqueue.c (original)
+++ subversion/trunk/subversion/libsvn_wc/workqueue.c Thu May 20 15:47:19 2010
@@ -491,14 +491,14 @@ verify_pristine_present(svn_wc__db_t *db
   svn_node_kind_t check_kind;
 
   /* Verify that one of the two text bases are present.  */
-  SVN_ERR(svn_wc__text_base_path(&base_abspath, db, local_abspath,
-                                 scratch_pool));
+  SVN_ERR(svn_wc__text_base_path_to_read(&base_abspath, db, local_abspath,
+                                         scratch_pool));
   SVN_ERR(svn_io_check_path(base_abspath, &check_kind, scratch_pool));
   if (check_kind == svn_node_file)
     return SVN_NO_ERROR;
 
-  SVN_ERR(svn_wc__text_revert_path(&base_abspath, db, local_abspath,
-                                   scratch_pool));
+  SVN_ERR(svn_wc__text_revert_path_to_read(&base_abspath, db, local_abspath,
+                                           scratch_pool));
   SVN_ERR(svn_io_check_path(base_abspath, &check_kind, scratch_pool));
   if (check_kind == svn_node_file)
     return SVN_NO_ERROR;
@@ -1419,8 +1419,9 @@ log_do_committed(svn_wc__db_t *db,
           /* If the working file was overwritten (due to re-translation)
              or touched (due to +x / -x), then use *that* textual
              timestamp instead. */
-          SVN_ERR(svn_wc__text_base_path(&base_abspath, db, local_abspath,
-                                         pool));
+          SVN_ERR(svn_wc__text_base_path_to_read(&base_abspath,
+                                                 db, local_abspath,
+                                                 pool));
           SVN_ERR(svn_io_stat(&basef_finfo, base_abspath,
                               APR_FINFO_MIN | APR_FINFO_LINK,
                               pool));



Re: svn commit: r946676 - in /subversion/trunk/subversion/libsvn_wc: adm_files.c adm_files.h adm_ops.c diff.c update_editor.c workqueue.c

Posted by Julian Foad <ju...@wandisco.com>.
On Thu, 2010-05-20, Greg Stein wrote:
> On Thu, May 20, 2010 at 11:47,  <ju...@apache.org> wrote:
> > Author: julianfoad
> > Date: Thu May 20 15:47:19 2010
> > New Revision: 946676
> >
> > URL: http://svn.apache.org/viewvc?rev=946676&view=rev
> > Log:
> > Replace read-only uses of svn_wc__text_base_path() and similar with new
> > functions that are named to indicate this usage.  The new functions simply
> > forward the call to the original functions, for now, but separating the
> > read-only uses from the writes should make it easier to migrate them to use
> > the WC-NG Pristine Store; at least it helps me to comprehend that process.
> >
> > * subversion/libsvn_wc/adm_files.h,
> >  subversion/libsvn_wc/adm_files.c
> >  (svn_wc__text_revert_path_to_read, svn_wc__ultimate_text_base_path,
> >   svn_wc__ultimate_text_base_path_to_read): New functions.
> >  (svn_wc__get_pristine_base_contents, svn_wc__get_pristine_contents): Use
> >    the new functions.
> >
> > * subversion/libsvn_wc/adm_ops.c
> >  (process_committed_leaf, svn_wc_get_pristine_copy_path): Use the new
> >    functions.
> >
> > * subversion/libsvn_wc/diff.c
> >  (get_nearest_pristine_text_as_file, report_wc_file_as_added): Use the new
> >    functions.
> >
> > * subversion/libsvn_wc/update_editor.c
> >  (get_pristine_base_path): Move+rename to svn_wc__ultimate_text_base_path().
> >  (merge_file, close_file): Use the new functions.
> >
> > * subversion/libsvn_wc/workqueue.c
> >  (verify_pristine_present, log_do_committed): Use the new functions.
> 
> Most of these changes are now using svn_wc__text_base_path_to_read(),
> which is not one of these "new functions". So... either the log
> message needs tweaking because it implies something else, or you
> actually intended to use the new functions, but the code didn't get
> that far.

I did mean "Use the new functions introduced here and the one introduced
previously".  I have substantially rewritten the log message.

> (and there is that "ultimate" again)

Yup.  For now, when you see "ultimate base", read "WC-NG BASE_NODE
table".  I'll replace it with something else as soon as we can find
something better.  Or even sooner.  I agree it sucks.  I thought it was
clearer than "pristine base" which it replaced.

> I know you simply ported existing code over, but with your series of
> changes the (newly-named) ultimate path thingy can check for replaced
> using svn_wc__internal_is_replaced() rather than fetching an entry. It
> has the same semantics if a node is present. It may throw
> SVN_ERR_WC_PATH_NOT_FOUND, which you'd need to catch to replace that
> "entry != NULL" condition.

Excellent.  Will do.

Thanks.
- Julian


Re: svn commit: r946676 - in /subversion/trunk/subversion/libsvn_wc: adm_files.c adm_files.h adm_ops.c diff.c update_editor.c workqueue.c

Posted by Greg Stein <gs...@gmail.com>.
On Thu, May 20, 2010 at 11:47,  <ju...@apache.org> wrote:
> Author: julianfoad
> Date: Thu May 20 15:47:19 2010
> New Revision: 946676
>
> URL: http://svn.apache.org/viewvc?rev=946676&view=rev
> Log:
> Replace read-only uses of svn_wc__text_base_path() and similar with new
> functions that are named to indicate this usage.  The new functions simply
> forward the call to the original functions, for now, but separating the
> read-only uses from the writes should make it easier to migrate them to use
> the WC-NG Pristine Store; at least it helps me to comprehend that process.
>
> * subversion/libsvn_wc/adm_files.h,
>  subversion/libsvn_wc/adm_files.c
>  (svn_wc__text_revert_path_to_read, svn_wc__ultimate_text_base_path,
>   svn_wc__ultimate_text_base_path_to_read): New functions.
>  (svn_wc__get_pristine_base_contents, svn_wc__get_pristine_contents): Use
>    the new functions.
>
> * subversion/libsvn_wc/adm_ops.c
>  (process_committed_leaf, svn_wc_get_pristine_copy_path): Use the new
>    functions.
>
> * subversion/libsvn_wc/diff.c
>  (get_nearest_pristine_text_as_file, report_wc_file_as_added): Use the new
>    functions.
>
> * subversion/libsvn_wc/update_editor.c
>  (get_pristine_base_path): Move+rename to svn_wc__ultimate_text_base_path().
>  (merge_file, close_file): Use the new functions.
>
> * subversion/libsvn_wc/workqueue.c
>  (verify_pristine_present, log_do_committed): Use the new functions.

Most of these changes are now using svn_wc__text_base_path_to_read(),
which is not one of these "new functions". So... either the log
message needs tweaking because it implies something else, or you
actually intended to use the new functions, but the code didn't get
that far.

(and there is that "ultimate" again)

I know you simply ported existing code over, but with your series of
changes the (newly-named) ultimate path thingy can check for replaced
using svn_wc__internal_is_replaced() rather than fetching an entry. It
has the same semantics if a node is present. It may throw
SVN_ERR_WC_PATH_NOT_FOUND, which you'd need to catch to replace that
"entry != NULL" condition.

Cheers,
-g