You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by gs...@apache.org on 2010/03/25 20:24:42 UTC

svn commit: r927552 - /subversion/trunk/subversion/libsvn_wc/wc_db.c

Author: gstein
Date: Thu Mar 25 19:24:42 2010
New Revision: 927552

URL: http://svn.apache.org/viewvc?rev=927552&view=rev
Log:
Break out the guts of svn_wc__db_wq_add() into an internal helper function
for future support where work items are passed into db_op_*().

* subversion/libsvn_wc/wc_db.c:
  (add_single_work_item): new helper function to insert a single row into
    the WORK_QUEUE table.
  (add_work_items): new function to insert 0 or more work items into a
    given SDB.
  (svn_wc__db_wq_add): gut this and just call add_work_items()

Modified:
    subversion/trunk/subversion/libsvn_wc/wc_db.c

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=927552&r1=927551&r2=927552&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Thu Mar 25 19:24:42 2010
@@ -1474,6 +1474,62 @@ flush_entries(const svn_wc__db_pdh_t *pd
 }
 
 
+/* Add a single WORK_ITEM into the given SDB's WORK_QUEUE table. This does
+   not perform its work within a transaction, assuming the caller will
+   manage that.  */
+static svn_error_t *
+add_single_work_item(svn_sqlite__db_t *sdb,
+                     const svn_skel_t *work_item,
+                     apr_pool_t *scratch_pool)
+{
+  svn_stringbuf_t *serialized;
+  svn_sqlite__stmt_t *stmt;
+
+  serialized = svn_skel__unparse(work_item, scratch_pool);
+  SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_INSERT_WORK_ITEM));
+  SVN_ERR(svn_sqlite__bind_blob(stmt, 1, serialized->data, serialized->len));
+  return svn_error_return(svn_sqlite__insert(NULL, stmt));
+}
+
+
+/* Add work item(s) to the given SDB. Also see add_one_work_item(). This
+   SKEL is usually passed to the various wc_db operation functions. It may
+   be NULL, indicating no additional work items are needed, it may be a
+   single work item, or it may be a list of work items.  */
+static svn_error_t *
+add_work_items(svn_sqlite__db_t *sdb,
+               const svn_skel_t *skel,
+               apr_pool_t *scratch_pool)
+{
+  apr_pool_t *iterpool;
+
+  /* Maybe there are no work items to insert.  */
+  if (skel == NULL)
+    return SVN_NO_ERROR;
+
+  /* Should have a list.  */
+  SVN_ERR_ASSERT(!skel->is_atom);
+
+  /* If SKEL has an atom as its first child, then this is a work item
+     (and that atom is one of the OP_* values).  */
+  if (skel->children->is_atom)
+    return svn_error_return(add_single_work_item(sdb, skel, scratch_pool));
+
+  /* SKEL is a list-of-lists, aka list of work items.  */
+
+  iterpool = svn_pool_create(scratch_pool);
+  for (skel = skel->children; skel; skel = skel->next)
+    {
+      svn_pool_clear(iterpool);
+
+      SVN_ERR(add_single_work_item(sdb, skel, iterpool));
+    }
+  svn_pool_destroy(iterpool);
+
+  return SVN_NO_ERROR;
+}
+
+
 /* */
 static svn_error_t *
 create_db(svn_sqlite__db_t **sdb,
@@ -5221,8 +5277,6 @@ svn_wc__db_wq_add(svn_wc__db_t *db,
 {
   svn_wc__db_pdh_t *pdh;
   const char *local_relpath;
-  svn_stringbuf_t *serialized;
-  svn_sqlite__stmt_t *stmt;
 
   SVN_ERR_ASSERT(svn_dirent_is_absolute(wri_abspath));
   SVN_ERR_ASSERT(work_item != NULL);
@@ -5252,12 +5306,10 @@ svn_wc__db_wq_add(svn_wc__db_t *db,
     }
 #endif
 
-  serialized = svn_skel__unparse(work_item, scratch_pool);
-
-  SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
-                                    STMT_INSERT_WORK_ITEM));
-  SVN_ERR(svn_sqlite__bind_blob(stmt, 1, serialized->data, serialized->len));
-  return svn_error_return(svn_sqlite__insert(NULL, stmt));
+  /* Add the work item(s) to the WORK_QUEUE.  */
+  return svn_error_return(add_work_items(pdh->wcroot->sdb,
+                                         work_item,
+                                         scratch_pool));
 }
 
 



Re: svn commit: r927552 - /subversion/trunk/subversion/libsvn_wc/wc_db.c

Posted by Julian Foad <ju...@wandisco.com>.
Philip Martin wrote:
> gstein@apache.org writes:
> 
> > Author: gstein
> > Date: Thu Mar 25 19:24:42 2010
> > New Revision: 927552
> >
> > URL: http://svn.apache.org/viewvc?rev=927552&view=rev
> > Log:
> > Break out the guts of svn_wc__db_wq_add() into an internal helper function
> > for future support where work items are passed into db_op_*().
> >
> > * subversion/libsvn_wc/wc_db.c:
> >   (add_single_work_item): new helper function to insert a single row into
> >     the WORK_QUEUE table.
> >   (add_work_items): new function to insert 0 or more work items into a
> >     given SDB.
> >   (svn_wc__db_wq_add): gut this and just call add_work_items()
> >
> > Modified:
> >     subversion/trunk/subversion/libsvn_wc/wc_db.c
> 
> This causes db-test to fail. svn_wc__db_wq_add used to accept atoms
> and now requires a list.

Bert fixed it in r927792.

- Julian


Re: svn commit: r927552 - /subversion/trunk/subversion/libsvn_wc/wc_db.c

Posted by Philip Martin <ph...@wandisco.com>.
gstein@apache.org writes:

> Author: gstein
> Date: Thu Mar 25 19:24:42 2010
> New Revision: 927552
>
> URL: http://svn.apache.org/viewvc?rev=927552&view=rev
> Log:
> Break out the guts of svn_wc__db_wq_add() into an internal helper function
> for future support where work items are passed into db_op_*().
>
> * subversion/libsvn_wc/wc_db.c:
>   (add_single_work_item): new helper function to insert a single row into
>     the WORK_QUEUE table.
>   (add_work_items): new function to insert 0 or more work items into a
>     given SDB.
>   (svn_wc__db_wq_add): gut this and just call add_work_items()
>
> Modified:
>     subversion/trunk/subversion/libsvn_wc/wc_db.c

This causes db-test to fail. svn_wc__db_wq_add used to accept atoms
and now requires a list.

-- 
Philip