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/05/08 06:33:13 UTC

svn commit: r942306 - in /subversion/trunk/subversion/libsvn_wc: wc_db.c workqueue.c workqueue.h

Author: gstein
Date: Sat May  8 04:33:12 2010
New Revision: 942306

URL: http://svn.apache.org/viewvc?rev=942306&view=rev
Log:
Introduce a utility function for merging work items into a larger list.

* subversion/libsvn_wc/workqueue.h:
  (SVN_WC__SINGLE_WORK_ITEM): new macro to determine whether a skel is a
    single work item, or a list of them.
  (svn_wc__wq_merge): new declaration

* subversion/libsvn_wc/workqueue.c:
  (svn_wc__wq_merge): new function

* subversion/libsvn_wc/wc_db.c:
  (add_work_items): use SVN_WC__SINGLE_WORK_ITEM instead of the longhand
    skel work.

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

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=942306&r1=942305&r2=942306&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Sat May  8 04:33:12 2010
@@ -43,6 +43,7 @@
 #include "lock.h"
 #include "tree_conflicts.h"
 #include "wc_db_pdh.h"
+#include "workqueue.h"
 
 #include "svn_private_config.h"
 #include "private/svn_sqlite.h"
@@ -1593,9 +1594,8 @@ add_work_items(svn_sqlite__db_t *sdb,
   /* 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)
+  /* Is the list a single work item? Or a list of work items?  */
+  if (SVN_WC__SINGLE_WORK_ITEM(skel))
     return svn_error_return(add_single_work_item(sdb, skel, scratch_pool));
 
   /* SKEL is a list-of-lists, aka list of work items.  */

Modified: subversion/trunk/subversion/libsvn_wc/workqueue.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/workqueue.c?rev=942306&r1=942305&r2=942306&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/workqueue.c (original)
+++ subversion/trunk/subversion/libsvn_wc/workqueue.c Sat May  8 04:33:12 2010
@@ -2363,3 +2363,51 @@ svn_wc__wq_run(svn_wc__db_t *db,
   svn_pool_destroy(iterpool);
   return SVN_NO_ERROR;
 }
+
+
+svn_skel_t *
+svn_wc__wq_merge(svn_skel_t *work_item1,
+                 svn_skel_t *work_item2,
+                 apr_pool_t *result_pool)
+{
+  /* If either argument is NULL, then just return the other.  */
+  if (work_item1 == NULL)
+    return work_item2;
+  if (work_item2 == NULL)
+    return work_item1;
+
+  /* We have two items. Figure out how to join them.  */
+  if (SVN_WC__SINGLE_WORK_ITEM(work_item1))
+    {
+      if (SVN_WC__SINGLE_WORK_ITEM(work_item2))
+        {
+          /* Both are singular work items. Construct a list, then put
+             both work items into it (in the proper order).  */
+
+          svn_skel_t *result = svn_skel__make_empty_list(result_pool);
+
+          svn_skel__prepend(work_item2, result);
+          svn_skel__prepend(work_item1, result);
+          return result;
+        }
+
+      /* WORK_ITEM2 is a list of work items. We can simply shove WORK_ITEM1
+         in the front to keep the ordering.  */
+      svn_skel__prepend(work_item1, work_item2);
+      return work_item2;
+    }
+  /* WORK_ITEM1 is a list of work items.  */
+
+  if (SVN_WC__SINGLE_WORK_ITEM(work_item2))
+    {
+      /* Put WORK_ITEM2 onto the end of the WORK_ITEM1 list.  */
+      svn_skel__append(work_item1, work_item2);
+      return work_item1;
+    }
+
+  /* We have two lists of work items. We need to chain all of the work
+     items into one big list. We will leave behind the WORK_ITEM2 skel,
+     as we only want its children.  */
+  svn_skel__append(work_item1, work_item2->children);
+  return work_item1;
+}

Modified: subversion/trunk/subversion/libsvn_wc/workqueue.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/workqueue.h?rev=942306&r1=942305&r2=942306&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/workqueue.h (original)
+++ subversion/trunk/subversion/libsvn_wc/workqueue.h Sat May  8 04:33:12 2010
@@ -52,6 +52,34 @@ extern "C" {
 #endif /* __cplusplus */
 
 
+/* Returns TRUE if WI refers to a single work item. Returns FALSE if
+   WI is a list of work items. WI must not be NULL.
+
+   A work item looks like: (OP_CODE arg1 arg2 ...)
+
+   If we see OP_CODE (an atom) as WI's first child, then this is a
+   single work item. Otherwise, it is a list of work items.  */
+#define SVN_WC__SINGLE_WORK_ITEM(wi) ((wi)->children->is_atom)
+
+
+/* Combine WORK_ITEM1 and WORK_ITEM2 into a single, resulting work item.
+
+   Each of the WORK_ITEM parameters may have one of three values:
+
+     NULL                          no work item
+     (OPCODE arg1 arg2 ...)        single work item
+     ((OPCODE ...) (OPCODE ...))   multiple work items
+
+   These will be combined as appropriate, and returned in one of the
+   above three styles.
+
+   The resulting list will be ordered: WORK_ITEM1 first, then WORK_ITEM2  */
+svn_skel_t *
+svn_wc__wq_merge(svn_skel_t *work_item1,
+                 svn_skel_t *work_item2,
+                 apr_pool_t *result_pool);
+
+
 /* For the WCROOT identified by the DB and WRI_ABSPATH pair, run any
    work items that may be present in its workqueue.  */
 svn_error_t *