subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1357281 - in /subversion/trunk/subversion/libsvn_wc: conflicts.c conflicts.h copy.c wc-queries.sql wc_db.c wc_db.h
Date Wed, 04 Jul 2012 14:44:41 GMT
Author: rhuijben
Date: Wed Jul  4 14:44:41 2012
New Revision: 1357281

URL: http://svn.apache.org/viewvc?rev=1357281&view=rev
Log:
Prepare one more code path for switching to conflict skels: the
code to avoid copying conflit marker files from 'svn copy'.

Make the wc_db api more generic, assuming that the current only caller
only uses a lookup to check if paths are in the list.

* subversion/libsvn_wc/conflicts.c
  (svn_wc__conflict_read_markers): New function.

* subversion/libsvn_wc/conflicts.h
  (svn_wc__conflict_read_markers): New function.

* subversion/libsvn_wc/copy.c
  (copy_versioned_dir): Assume that svn_wc__db_get_conflict_marker_files
    returns absolute paths instead of just basenames.

* subversion/libsvn_wc/wc-queries.sql
  (STMT_SELECT_CONFLICT_VICTIMS): Also check conflict_data for conflicts.
    Return conflict_data as second column.

* subversion/libsvn_wc/wc_db.c
  (svn_wc__db_read_conflict_victims): Update statement reference.
  (marker_files_baton): New struct.
  (get_conflict_marker_files): Use baton. Add implementation for conflict skel
    storage.
  (svn_wc__db_get_conflict_marker_files): Update caller.

* subversion/libsvn_wc/wc_db.h
  (svn_wc__db_get_conflict_marker_files): Update documentation.

Modified:
    subversion/trunk/subversion/libsvn_wc/conflicts.c
    subversion/trunk/subversion/libsvn_wc/conflicts.h
    subversion/trunk/subversion/libsvn_wc/copy.c
    subversion/trunk/subversion/libsvn_wc/wc-queries.sql
    subversion/trunk/subversion/libsvn_wc/wc_db.c
    subversion/trunk/subversion/libsvn_wc/wc_db.h

Modified: subversion/trunk/subversion/libsvn_wc/conflicts.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/conflicts.c?rev=1357281&r1=1357280&r2=1357281&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/conflicts.c (original)
+++ subversion/trunk/subversion/libsvn_wc/conflicts.c Wed Jul  4 14:44:41 2012
@@ -870,6 +870,47 @@ svn_wc__conflict_read_tree_conflict(svn_
   return SVN_NO_ERROR;
 }
 
+svn_error_t *
+svn_wc__conflict_read_markers(const apr_array_header_t **markers,
+                              svn_wc__db_t *db,
+                              const char *wri_abspath,
+                              const svn_skel_t *conflict_skel,
+                              apr_pool_t *result_pool,
+                              apr_pool_t *scratch_pool)
+{
+  const svn_skel_t *conflict;
+  apr_array_header_t *list = NULL;
+
+  SVN_ERR_ASSERT(conflict_skel != NULL);
+
+  for (conflict = conflict_skel->children->next->children;
+       conflict;
+       conflict = conflict->next)
+    {
+      const svn_skel_t *marker;
+
+      for (marker = conflict->next->children;
+           marker;
+           marker = marker->next)
+        {
+          if (! marker->is_atom)
+            continue;
+
+          if (! list)
+            list = apr_array_make(result_pool, 4, sizeof(const char *));
+
+          SVN_ERR(svn_wc__db_from_relpath(
+                        &APR_ARRAY_PUSH(list, const char*),
+                        db, wri_abspath,
+                        apr_pmemdup(scratch_pool, marker->data, marker->len),
+                        result_pool, scratch_pool));
+        }
+    }
+  *markers = list;
+
+  return SVN_NO_ERROR;
+}
+
 /* --------------------------------------------------------------------
  */
 /* Helper for svn_wc__conflict_create_markers */

Modified: subversion/trunk/subversion/libsvn_wc/conflicts.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/conflicts.h?rev=1357281&r1=1357280&r2=1357281&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/conflicts.h (original)
+++ subversion/trunk/subversion/libsvn_wc/conflicts.h Wed Jul  4 14:44:41 2012
@@ -302,6 +302,19 @@ svn_wc__conflict_read_tree_conflict(svn_
                                     apr_pool_t *result_pool,
                                     apr_pool_t *scratch_pool);
 
+/* Reads in *MARKERS a list of const char * absolute paths of the marker files
+   referenced from CONFLICT_SKEL.
+ * Allocate the result in RESULT_POOL. Perform temporary allocations in
+ * SCRATCH_POOL.
+ */
+svn_error_t *
+svn_wc__conflict_read_markers(const apr_array_header_t **markers,
+                              svn_wc__db_t *db,
+                              const char *wri_abspath,
+                              const svn_skel_t *conflict_skel,
+                              apr_pool_t *result_pool,
+                              apr_pool_t *scratch_pool);
+
 /* Create the necessary marker files for the conflicts stored in
  * CONFLICT_SKEL and return the work items to fill the markers from
  * the work queue.

Modified: subversion/trunk/subversion/libsvn_wc/copy.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/copy.c?rev=1357281&r1=1357280&r2=1357281&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/copy.c (original)
+++ subversion/trunk/subversion/libsvn_wc/copy.c Wed Jul  4 14:44:41 2012
@@ -484,10 +484,6 @@ copy_versioned_dir(svn_wc__db_t *db,
           if (svn_wc_is_adm_dir(name, iterpool))
             continue;
 
-          if (marker_files &&
-              apr_hash_get(marker_files, name, APR_HASH_KEY_STRING))
-            continue;
-
           if (cancel_func)
             SVN_ERR(cancel_func(cancel_baton));
 
@@ -495,6 +491,11 @@ copy_versioned_dir(svn_wc__db_t *db,
           unver_src_abspath = svn_dirent_join(src_abspath, name, iterpool);
           unver_dst_abspath = svn_dirent_join(dst_abspath, name, iterpool);
 
+          if (marker_files &&
+              apr_hash_get(marker_files, unver_src_abspath,
+                           APR_HASH_KEY_STRING))
+            continue;
+
           SVN_ERR(copy_to_tmpdir(&work_item, NULL, db, unver_src_abspath,
                                  unver_dst_abspath, tmpdir_abspath,
                                  TRUE /* recursive */, TRUE /* unversioned */,

Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=1357281&r1=1357280&r2=1357281&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Wed Jul  4 14:44:41 2012
@@ -717,13 +717,13 @@ WHERE refcount = 0
 DELETE FROM pristine
 WHERE checksum = ?1 AND refcount = 0
 
--- STMT_SELECT_ACTUAL_CONFLICT_VICTIMS
-SELECT local_relpath
+-- STMT_SELECT_CONFLICT_VICTIMS
+SELECT local_relpath, conflict_data
 FROM actual_node
 WHERE wc_id = ?1 AND parent_relpath = ?2 AND
-  NOT ((prop_reject IS NULL) AND (conflict_old IS NULL)
+  NOT ((conflict_data IS NULL) AND (conflict_old IS NULL)
        AND (conflict_new IS NULL) AND (conflict_working IS NULL)
-       AND (tree_conflict_data IS NULL))
+       AND (prop_reject IS NULL) AND (tree_conflict_data IS NULL))
 
 -- STMT_SELECT_CONFLICT_MARKER_FILES1
 SELECT prop_reject

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1357281&r1=1357280&r2=1357281&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Wed Jul  4 14:44:41 2012
@@ -11483,7 +11483,7 @@ svn_wc__db_read_conflict_victims(const a
 
   /* Look for text, tree and property conflicts in ACTUAL */
   SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
-                                    STMT_SELECT_ACTUAL_CONFLICT_VICTIMS));
+                                    STMT_SELECT_CONFLICT_VICTIMS));
   SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, local_relpath));
 
   new_victims = apr_array_make(result_pool, 0, sizeof(const char *));
@@ -11505,6 +11505,16 @@ svn_wc__db_read_conflict_victims(const a
   return SVN_NO_ERROR;
 }
 
+/* Baton for get_conflict_marker_files */
+struct marker_files_baton
+{
+  apr_pool_t *result_pool;
+  apr_hash_t *marker_files;
+#if SVN_WC__VERSION >= SVN_WC__USES_CONFLICT_SKELS
+  svn_wc__db_t *db;
+#endif
+};
+
 /* Locked implementation for svn_wc__db_get_conflict_marker_files */
 static svn_error_t *
 get_conflict_marker_files(void *baton, svn_wc__db_wcroot_t *wcroot,
@@ -11512,9 +11522,11 @@ get_conflict_marker_files(void *baton, s
 {
   svn_sqlite__stmt_t *stmt;
   svn_boolean_t have_row;
-  apr_hash_t *marker_files = baton;
-  apr_pool_t *result_pool = apr_hash_pool_get(marker_files);
+  struct marker_files_baton *mfb = baton;
+  apr_hash_t *marker_files = mfb->marker_files;
+  apr_pool_t *result_pool = mfb->result_pool;
 
+#if SVN_WC__VERSION < SVN_WC__USES_CONFLICT_SKELS
   /* Look for property conflicts on the directory in ACTUAL.
      (A directory can't have text conflicts) */
   SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
@@ -11525,18 +11537,18 @@ get_conflict_marker_files(void *baton, s
   if (have_row)
     {
       const char *marker_relpath;
-      const char *base_name;
 
       marker_relpath = svn_sqlite__column_text(stmt, 0, NULL);
 
-      base_name = svn_relpath_skip_ancestor(local_relpath, marker_relpath);
-
-      /* Verify if the marker file is directly within LOCAL_ABSPATH */
-      if (base_name && svn_path_is_single_path_component(base_name))
+      if (marker_relpath)
         {
-          base_name = apr_pstrdup(result_pool, base_name);
-          apr_hash_set(marker_files, base_name, APR_HASH_KEY_STRING,
-                       base_name);
+          const char *marker_abspath;
+
+          marker_abspath = svn_dirent_join(wcroot->abspath, marker_relpath,
+                                           result_pool);
+
+          apr_hash_set(marker_files, marker_abspath, APR_HASH_KEY_STRING,
+                       "");
         }
     }
   SVN_ERR(svn_sqlite__reset(stmt));
@@ -11556,26 +11568,83 @@ get_conflict_marker_files(void *baton, s
       for (i = 0; i < 4; i++)
         {
           const char *marker_relpath;
-          const char *base_name;
 
           marker_relpath = svn_sqlite__column_text(stmt, i, NULL);
 
-          if (!marker_relpath)
-            continue;
+          if (marker_relpath)
+            {
+              const char *marker_abspath;
 
-          base_name = svn_relpath_skip_ancestor(local_relpath, marker_relpath);
+              marker_abspath = svn_dirent_join(wcroot->abspath, marker_relpath,
+                                               result_pool);
 
-          /* Verify if the marker file is directly within LOCAL_ABSPATH */
-          if (base_name && svn_path_is_single_path_component(base_name))
-            {
-              base_name = apr_pstrdup(result_pool, base_name);
-              apr_hash_set(marker_files, base_name, APR_HASH_KEY_STRING,
-                           base_name);
+              apr_hash_set(marker_files, marker_abspath, APR_HASH_KEY_STRING,
+                           "");
             }
         }
 
       SVN_ERR(svn_sqlite__step(&have_row, stmt));
     }
+#else
+  SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+                                    STMT_SELECT_ACTUAL_NODE));
+  SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, local_relpath));
+  SVN_ERR(svn_sqlite__step(&have_row, stmt));
+
+  if (have_row && !svn_sqlite__column_is_null(stmt, 2))
+    {
+      apr_size_t len;
+      const void *data = svn_sqlite__column_blob(stmt, 2, &len, scratch_pool);
+      svn_skel_t *conflicts;
+      const apr_array_header_t *markers;
+      int i;
+
+      conflicts = svn_skel__parse(data, len, scratch_pool);
+
+      /* ### ADD markers to *marker_files */
+      SVN_ERR(svn_wc__conflict_read_markers(&markers, mfb->db, wcroot->abspath,
+                                            conflicts,
+                                            result_pool, scratch_pool));
+
+      for (i = 0; markers && (i < markers->nelts); i++)
+        {
+          const char *marker_abspath = APR_ARRAY_IDX(markers, i, const char*);
+
+          apr_hash_set(marker_files, marker_abspath, APR_HASH_KEY_STRING, "");
+        }
+    }
+  SVN_ERR(svn_sqlite__reset(stmt));
+
+  SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+                                    STMT_SELECT_CONFLICT_VICTIMS));
+  SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, local_relpath));
+  SVN_ERR(svn_sqlite__step(&have_row, stmt));
+
+  while (have_row)
+    {
+      apr_size_t len;
+      const void *data = svn_sqlite__column_blob(stmt, 2, &len, scratch_pool);
+      svn_skel_t *conflicts;
+      const apr_array_header_t *markers;
+      int i;
+
+      conflicts = svn_skel__parse(data, len, scratch_pool);
+
+      /* ### ADD markers to *marker_files */
+      SVN_ERR(svn_wc__conflict_read_markers(&markers, mfb->db, wcroot->abspath,
+                                            conflicts,
+                                            result_pool, scratch_pool));
+
+      for (i = 0; markers && (i < markers->nelts); i++)
+        {
+          const char *marker_abspath = APR_ARRAY_IDX(markers, i, const char*);
+
+          apr_hash_set(marker_files, marker_abspath, APR_HASH_KEY_STRING, "");
+        }
+
+      SVN_ERR(svn_sqlite__step(&have_row, stmt));
+    }
+#endif
 
   return svn_error_trace(svn_sqlite__reset(stmt));
 }
@@ -11589,20 +11658,24 @@ svn_wc__db_get_conflict_marker_files(apr
 {
   svn_wc__db_wcroot_t *wcroot;
   const char *local_relpath;
-  apr_hash_t *markers;
+  struct marker_files_baton mfb;
 
   /* The parent should be a working copy directory. */
   SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath, db,
                               local_abspath, scratch_pool, scratch_pool));
   VERIFY_USABLE_WCROOT(wcroot);
 
-  markers = apr_hash_make(result_pool);
+  mfb.result_pool = result_pool;
+  mfb.marker_files = apr_hash_make(result_pool);
+#if SVN_WC__VERSION >= SVN_WC__USES_CONFLICT_SKELS
+  mfb.db = db;
+#endif
 
   SVN_ERR(svn_wc__db_with_txn(wcroot, local_relpath, get_conflict_marker_files,
-                              markers, scratch_pool));
+                              &mfb, scratch_pool));
 
-  if (apr_hash_count(markers))
-    *marker_files = markers;
+  if (apr_hash_count(mfb.marker_files))
+    *marker_files = mfb.marker_files;
   else
     *marker_files = NULL;
 

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=1357281&r1=1357280&r2=1357281&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Wed Jul  4 14:44:41 2012
@@ -2106,9 +2106,9 @@ svn_wc__db_read_conflict_victims(const a
                                  apr_pool_t *result_pool,
                                  apr_pool_t *scratch_pool);
 
-/* Read into *MARKER_FILES the basenames of the immediate children of
-   LOCAL_ABSPATH in DB that are unversioned marker files for text or
-   property conflicts.  The files may have been deleted by the user.
+/* Read into *MARKER_FILES the absolute paths of the marker files
+   of conflicts stored on LOCAL_ABSPATH and its immediate children in DB.
+   The on-disk files may have been deleted by the user.
 
    Allocate *MARKER_FILES in RESULT_POOL and do temporary allocations
    in SCRATCH_POOL */



Mime
View raw message