Author: neels
Date: Wed Mar 10 22:00:38 2010
New Revision: 921588

URL: http://svn.apache.org/viewvc?rev=921588&view=rev
Log:
Strike the first blow at making svn_wc_[_]get_pristine_contents[2]() use wc-ng.

The previous implementation of svn_wc_get_pristine_contents2() assumed a
text-base file to always be present and never reflected a NULL return value to
the callers, other than advertised. This patch fixes that return value.

See also r921556, which prepared for this patch.

(Still TODO for 1.7: svn_wc_get_pristine_contents2() and
svn_wc__get_pristine_contents() should use the pristine store.)

* subversion/include/svn_wc.h
  (svn_wc_get_pristine_contents2): Comment.
    Properly define this function so that we know what to implement when the
    pristine store rolls out.

* subversion/libsvn_wc/adm_files.h
  (svn_wc__get_pristine_contents): Comment, point to 
svn_wc_get_pristine_contents2().

* subversion/libsvn_wc/adm_ops.c
  (svn_wc_get_pristine_contents2, svn_wc__get_pristine_contents): 
    Properly detect a node that has no pristine base using wc-db API. Return
    NULL as advertised (previously failed with an error complaining about a
    non-existing text-base file). Add assertion to make sure we covered all
    cases.

Modified:
    subversion/trunk/subversion/include/svn_wc.h
    subversion/trunk/subversion/libsvn_wc/adm_files.h
    subversion/trunk/subversion/libsvn_wc/adm_ops.c

Modified: subversion/trunk/subversion/include/svn_wc.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_wc.h?rev=921588&r1=921587&r2=921588&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_wc.h (original)
+++ subversion/trunk/subversion/include/svn_wc.h Wed Mar 10 22:00:38 2010
@@ -6424,10 +6424,24 @@ svn_wc_merge_prop_diffs(svn_wc_notify_st
                         apr_pool_t *pool);
 
 
-/** Given a @a path to a wc file, return a stream to the @a contents of
- * the pristine copy of the file.  Use @a wc_ctx to access the working
- * copy.This is needed so clients can do diffs.  If the WC has no
- * text-base, return a @c NULL instead of a stream.
+/** Given a @a path to a wc file, return in @a *contents a readonly stream to
+ * the pristine contents of the file that would serve as base content for the
+ * next commit. That means:
+ *
+ * When there is no change in node history scheduled, i.e. when there are only
+ * local text-mods, prop-mods or a delete, return the last checked-out or
+ * updated-/switched-to contents of the file.
+ *
+ * If the file is simply added or replaced (no copy-/move-here involved),
+ * set @a *contents to @c NULL.
+ *
+ * When the file has been locally copied-/moved-here, return the contents of
+ * the copy/move source (even if the copy-/move-here replaces a locally
+ * deleted file).
+ *
+ * If @local_abspath refers to an unversioned or non-existing path, return
+ * @c SVN_ERR_WC_PATH_NOT_FOUND. Use @a wc_ctx to access the working copy.
+ * @a contents may not be @c NULL (unlike @a *contents).
  *
  * @since New in 1.7. */
 svn_error_t *

Modified: subversion/trunk/subversion/libsvn_wc/adm_files.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/adm_files.h?rev=921588&r1=921587&r2=921588&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_files.h (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_files.h Wed Mar 10 22:00:38 2010
@@ -68,7 +68,9 @@ svn_wc__text_base_path(const char **resu
                        svn_boolean_t tmp,
                        apr_pool_t *pool);
 
-/* Set *CONTENTS to a readonly stream on the LOCAL_ABSPATH's base file. */
+/* Set *CONTENTS to a readonly stream on the LOCAL_ABSPATH's base file.
+ * For more detail, please see the description of
+ * svn_wc_get_pristine_contents2().*/
 svn_error_t *
 svn_wc__get_pristine_contents(svn_stream_t **contents,
                               svn_wc__db_t *db,

Modified: subversion/trunk/subversion/libsvn_wc/adm_ops.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/adm_ops.c?rev=921588&r1=921587&r2=921588&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_ops.c (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_ops.c Wed Mar 10 22:00:38 2010
@@ -2208,17 +2208,39 @@ svn_wc__get_pristine_contents(svn_stream
                               apr_pool_t *result_pool,
                               apr_pool_t *scratch_pool)
 {
+  svn_wc__db_status_t status;
   const char *text_base;
 
-  SVN_ERR(svn_wc__text_base_path(&text_base, db, local_abspath, FALSE,
-                                 scratch_pool));
-
-  if (text_base == NULL)
+  SVN_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,
+                               db, local_abspath, scratch_pool, scratch_pool));
+  if (status == svn_wc__db_status_added)
     {
-      *contents = NULL;
-      return SVN_NO_ERROR;
+      /* For an added node, we return an empty stream. Make sure this is not
+       * copied-here or moved-here, in which case we return the copy/move
+       * source's contents. */
+      SVN_ERR(svn_wc__db_scan_addition(&status,
+                                       NULL, NULL, NULL, NULL, NULL, NULL,
+                                       NULL, NULL,
+                                       db, local_abspath,
+                                       scratch_pool, scratch_pool));
+      if (status == svn_wc__db_status_added)
+        {
+          /* Simply added. The pristine base does not exist. */
+          *contents = NULL;
+          return SVN_NO_ERROR;
+        }
     }
 
+  /* ### TODO: use pristine store. */
+  /* ### TODO: check for non-file node. */
+
+  SVN_ERR(svn_wc__text_base_path(&text_base, db, local_abspath, FALSE,
+                                 scratch_pool));
+  SVN_ERR_ASSERT(text_base != NULL);
+
   return svn_stream_open_readonly(contents, text_base, result_pool,
                                   scratch_pool);
 }


Reply via email to