You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2016/01/31 15:29:20 UTC

svn commit: r1727822 - in /subversion/trunk/subversion: include/private/svn_fs_util.h include/svn_fs.h libsvn_fs/fs-loader.c libsvn_fs/fs-loader.h libsvn_fs_base/tree.c libsvn_fs_fs/tree.c libsvn_fs_util/fs-util.c libsvn_fs_x/tree.c

Author: stefan2
Date: Sun Jan 31 14:29:19 2016
New Revision: 1727822

URL: http://svn.apache.org/viewvc?rev=1727822&view=rev
Log:
Define a callback-based FS API to report changed paths.

The old API is not going to be deprecated until the majority of users have
been migrated.  Also, there is no backend that implements the new API, so
this will simply segfault when being called.  The next patch will fix this
by adding a fallback implementation for it.

* subversion/include/svn_fs.h
  (svn_fs_path_change3_t): Declare the new path change data type.  Lose
                           the unusable noderev ID and add the path, so
                           this struct is now self-sufficient.
  (svn_fs_path_change3_create): Declare a suitable constructor to help
                                future binary compatibility.
  (svn_fs_path_change_receiver_t,
   svn_fs_paths_changed3): The actual new API & callback function type. 

* subversion/include/private/svn_fs_util.h
  (svn_fs__path_change_create_internal2): Declare a suitable private API
                                          to instantiate the new data
                                          struct - similar to the old one.

* subversion/libsvn_fs_util/fs-util.c
  (svn_fs__path_change_create_internal2): Implement the new internal API
                                          similar to the old one.

* subversion/libsvn_fs/fs-loader.h
  (root_vtable_t): Add entry for the new API.

* subversion/libsvn_fs/fs-loader.c
  (svn_fs_paths_changed3): Implement as simple vtable call.  This will
                           actually segfault for now b/c nobody provides
                           the function.
  (svn_fs_path_change3_create): Implement like svn_fs_path_change2_create.

* subversion/libsvn_fs_base/tree.c
* subversion/libsvn_fs_fs/tree.c
* subversion/libsvn_fs_x/tree.c
  (root_vtable): None of these backends actually implement the new API.

Modified:
    subversion/trunk/subversion/include/private/svn_fs_util.h
    subversion/trunk/subversion/include/svn_fs.h
    subversion/trunk/subversion/libsvn_fs/fs-loader.c
    subversion/trunk/subversion/libsvn_fs/fs-loader.h
    subversion/trunk/subversion/libsvn_fs_base/tree.c
    subversion/trunk/subversion/libsvn_fs_fs/tree.c
    subversion/trunk/subversion/libsvn_fs_util/fs-util.c
    subversion/trunk/subversion/libsvn_fs_x/tree.c

Modified: subversion/trunk/subversion/include/private/svn_fs_util.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_fs_util.h?rev=1727822&r1=1727821&r2=1727822&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_fs_util.h (original)
+++ subversion/trunk/subversion/include/private/svn_fs_util.h Sun Jan 31 14:29:19 2016
@@ -206,6 +206,15 @@ svn_fs__path_change_create_internal(cons
                                     svn_fs_path_change_kind_t change_kind,
                                     apr_pool_t *pool);
 
+/* Allocate an svn_fs_path_change3_t structure in RESULT_POOL, initialize
+   and return it.
+
+   Set the change_kind to CHANGE_KIND.  Set all other fields to their
+   _unknown, NULL or invalid value, respectively. */
+svn_fs_path_change3_t *
+svn_fs__path_change_create_internal2(svn_fs_path_change_kind_t change_kind,
+                                     apr_pool_t *result_pool);
+
 /* Append REL_PATH (which may contain slashes) to each path that exists in
    the mergeinfo INPUT, and return a new mergeinfo in *OUTPUT.  Deep
    copies the values.  Perform all allocations in POOL. */

Modified: subversion/trunk/subversion/include/svn_fs.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_fs.h?rev=1727822&r1=1727821&r2=1727822&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_fs.h (original)
+++ subversion/trunk/subversion/include/svn_fs.h Sun Jan 31 14:29:19 2016
@@ -1493,6 +1493,70 @@ typedef enum svn_fs_path_change_kind_t
  * by the commit API; this does not mean the new value is different from
  * the old value.
  *
+ * @since New in 1.10. */
+typedef struct svn_fs_path_change3_t
+{
+  /** path of the node that got changed. */
+  svn_string_t path;
+
+  /** kind of change */
+  svn_fs_path_change_kind_t change_kind;
+
+  /** what node kind is the path?
+      (Note: it is legal for this to be #svn_node_unknown.) */
+  svn_node_kind_t node_kind;
+
+  /** was the text touched?
+   * For node_kind=dir: always false. For node_kind=file:
+   *   modify:      true iff text touched.
+   *   add (copy):  true iff text touched.
+   *   add (plain): always true.
+   *   delete:      always false.
+   *   replace:     as for the add/copy part of the replacement.
+   */
+  svn_boolean_t text_mod;
+
+  /** were the properties touched?
+   *   modify:      true iff props touched.
+   *   add (copy):  true iff props touched.
+   *   add (plain): true iff props touched.
+   *   delete:      always false.
+   *   replace:     as for the add/copy part of the replacement.
+   */
+  svn_boolean_t prop_mod;
+
+  /** was the mergeinfo property touched?
+   *   modify:      } true iff svn:mergeinfo property add/del/mod
+   *   add (copy):  }          and fs format supports this flag.
+   *   add (plain): }
+   *   delete:      always false.
+   *   replace:     as for the add/copy part of the replacement.
+   * (Note: Pre-1.9 repositories will report #svn_tristate_unknown.)
+   */
+  svn_tristate_t mergeinfo_mod;
+
+  /** Copyfrom revision and path; this is only valid if copyfrom_known
+   * is true. */
+  svn_boolean_t copyfrom_known;
+  svn_revnum_t copyfrom_rev;
+  const char *copyfrom_path;
+
+  /* NOTE! Please update svn_fs_path_change3_create() when adding new
+     fields here. */
+} svn_fs_path_change3_t;
+
+
+/** Change descriptor.
+ *
+ * @note Fields may be added to the end of this structure in future
+ * versions.  Therefore, to preserve binary compatibility, users
+ * should not directly allocate structures of this type.
+ *
+ * @note The @c text_mod, @c prop_mod and @c mergeinfo_mod flags mean the
+ * text, properties and mergeinfo property (respectively) were "touched"
+ * by the commit API; this does not mean the new value is different from
+ * the old value.
+ *
  * @since New in 1.6. */
 typedef struct svn_fs_path_change2_t
 {
@@ -1582,6 +1646,57 @@ svn_fs_path_change2_create(const svn_fs_
                            svn_fs_path_change_kind_t change_kind,
                            apr_pool_t *pool);
 
+/**
+ * Allocate an #svn_fs_path_change3_t structure in @a result_pool,
+ * initialize and return it.
+ *
+ * Set the @c change_kind field to @a change_kind.  Set all other fields
+ * to their @c _unknown, @c NULL or invalid value, respectively.
+ *
+ * @since New in 1.10.
+ */
+svn_fs_path_change3_t *
+svn_fs_path_change3_create(svn_fs_path_change_kind_t change_kind,
+                           apr_pool_t *result_pool);
+
+/**
+ * Processing callback type used with svn_fs_paths_changed3.
+ *
+ * The @a baton is the baton pointer provided to svn_fs_paths_changed3
+ * and @a change is the path change to process.  You may modify its
+ * content and it will become invalid as soon as callback returns.
+ *
+ * Use @a scratch_pool for temporary allocations.
+ *
+ * @note The @c node_kind field in @a change may be #svn_node_unknown and
+ *       the @c copyfrom_known fields may be FALSE.
+ */
+typedef svn_error_t *(*svn_fs_path_change_receiver_t)(
+  void *baton,
+  svn_fs_path_change3_t *change,
+  apr_pool_t *scratch_pool);
+
+/** Determine what has changed under a @a root.
+ *
+ * For each changed path, invoke @a receiver with @a baton and the
+ * respective change.
+ *
+ * Callers can assume that this function takes time proportional to
+ * the amount of data output, and does not need to do tree crawls;
+ * however, it is possible that some of the @c node_kind fields in the
+ * #svn_fs_path_change3_t * values will be #svn_node_unknown or
+ * that and some of the @c copyfrom_known fields will be FALSE.
+ *
+ * Use @a scratch_pool for temporary allocations.
+ *
+ * @since New in 1.10.
+ */
+svn_error_t *
+svn_fs_paths_changed3(svn_fs_root_t *root,
+                      svn_fs_path_change_receiver_t receiver,
+                      void *baton,
+                      apr_pool_t *scratch_pool);
+
 /** Determine what has changed under a @a root.
  *
  * Allocate and return a hash @a *changed_paths2_p containing descriptions

Modified: subversion/trunk/subversion/libsvn_fs/fs-loader.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs/fs-loader.c?rev=1727822&r1=1727821&r2=1727822&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs/fs-loader.c (original)
+++ subversion/trunk/subversion/libsvn_fs/fs-loader.c Sun Jan 31 14:29:19 2016
@@ -1047,6 +1047,15 @@ svn_fs_paths_changed2(apr_hash_t **chang
 }
 
 svn_error_t *
+svn_fs_paths_changed3(svn_fs_root_t *root,
+                      svn_fs_path_change_receiver_t receiver,
+                      void *baton,
+                      apr_pool_t *scratch_pool)
+{
+  return root->vtable->report_changes(root, receiver, baton, scratch_pool);
+}
+
+svn_error_t *
 svn_fs_check_path(svn_node_kind_t *kind_p, svn_fs_root_t *root,
                   const char *path, apr_pool_t *pool)
 {
@@ -1905,6 +1914,13 @@ svn_fs_path_change2_create(const svn_fs_
   return svn_fs__path_change_create_internal(node_rev_id, change_kind, pool);
 }
 
+svn_fs_path_change3_t *
+svn_fs_path_change3_create(svn_fs_path_change_kind_t change_kind,
+                           apr_pool_t *result_pool)
+{
+  return svn_fs__path_change_create_internal2(change_kind, result_pool);
+}
+
 /* Return the library version number. */
 const svn_version_t *
 svn_fs_version(void)

Modified: subversion/trunk/subversion/libsvn_fs/fs-loader.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs/fs-loader.h?rev=1727822&r1=1727821&r2=1727822&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs/fs-loader.h (original)
+++ subversion/trunk/subversion/libsvn_fs/fs-loader.h Sun Jan 31 14:29:19 2016
@@ -301,6 +301,10 @@ typedef struct root_vtable_t
   svn_error_t *(*paths_changed)(apr_hash_t **changed_paths_p,
                                 svn_fs_root_t *root,
                                 apr_pool_t *pool);
+  svn_error_t *(*report_changes)(svn_fs_root_t *root,
+                                 svn_fs_path_change_receiver_t receiver,
+                                 void *baton,
+                                 apr_pool_t *scratch_pool);
 
   /* Generic node operations */
   svn_error_t *(*check_path)(svn_node_kind_t *kind_p, svn_fs_root_t *root,

Modified: subversion/trunk/subversion/libsvn_fs_base/tree.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_base/tree.c?rev=1727822&r1=1727821&r2=1727822&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_base/tree.c (original)
+++ subversion/trunk/subversion/libsvn_fs_base/tree.c Sun Jan 31 14:29:19 2016
@@ -5506,6 +5506,7 @@ base_get_mergeinfo(svn_mergeinfo_catalog
 
 static root_vtable_t root_vtable = {
   base_paths_changed,
+  NULL,
   base_check_path,
   base_node_history,
   base_node_id,

Modified: subversion/trunk/subversion/libsvn_fs_fs/tree.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/tree.c?rev=1727822&r1=1727821&r2=1727822&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/tree.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/tree.c Sun Jan 31 14:29:19 2016
@@ -4325,6 +4325,7 @@ fs_get_mergeinfo(svn_mergeinfo_catalog_t
 /* The vtable associated with root objects. */
 static root_vtable_t root_vtable = {
   fs_paths_changed,
+  NULL,
   svn_fs_fs__check_path,
   fs_node_history,
   svn_fs_fs__node_id,

Modified: subversion/trunk/subversion/libsvn_fs_util/fs-util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_util/fs-util.c?rev=1727822&r1=1727821&r2=1727822&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_util/fs-util.c (original)
+++ subversion/trunk/subversion/libsvn_fs_util/fs-util.c Sun Jan 31 14:29:19 2016
@@ -212,6 +212,21 @@ svn_fs__path_change_create_internal(cons
   return change;
 }
 
+svn_fs_path_change3_t *
+svn_fs__path_change_create_internal2(svn_fs_path_change_kind_t change_kind,
+                                     apr_pool_t *result_pool)
+{
+  svn_fs_path_change3_t *change;
+
+  change = apr_pcalloc(result_pool, sizeof(*change));
+  change->path.data = "";
+  change->change_kind = change_kind;
+  change->mergeinfo_mod = svn_tristate_unknown;
+  change->copyfrom_rev = SVN_INVALID_REVNUM;
+
+  return change;
+}
+
 svn_error_t *
 svn_fs__append_to_merged_froms(svn_mergeinfo_t *output,
                                svn_mergeinfo_t input,

Modified: subversion/trunk/subversion/libsvn_fs_x/tree.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/tree.c?rev=1727822&r1=1727821&r2=1727822&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/tree.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/tree.c Sun Jan 31 14:29:19 2016
@@ -3215,6 +3215,7 @@ x_get_mergeinfo(svn_mergeinfo_catalog_t
 /* The vtable associated with root objects. */
 static root_vtable_t root_vtable = {
   x_paths_changed,
+  NULL,
   svn_fs_x__check_path,
   x_node_history,
   x_node_id,