subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pbu...@apache.org
Subject svn commit: r1330583 [7/7] - in /subversion/branches/inheritable-props: ./ build/ build/generator/ build/generator/templates/ notes/ notes/merge-tracking/ subversion/bindings/javahl/src/org/apache/subversion/javahl/ subversion/bindings/swig/ruby/test/ ...
Date Wed, 25 Apr 2012 22:04:40 GMT
Modified: subversion/branches/inheritable-props/tools/client-side/svnmucc/svnmucc.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/tools/client-side/svnmucc/svnmucc.c?rev=1330583&r1=1330582&r2=1330583&view=diff
==============================================================================
--- subversion/branches/inheritable-props/tools/client-side/svnmucc/svnmucc.c (original)
+++ subversion/branches/inheritable-props/tools/client-side/svnmucc/svnmucc.c Wed Apr 25 22:04:36
2012
@@ -605,6 +605,12 @@ struct action {
   const svn_string_t *prop_value;
 };
 
+struct fetch_baton
+{
+  svn_ra_session_t *session;
+  svn_revnum_t head;
+};
+
 static svn_error_t *
 fetch_base_func(const char **filename,
                 void *baton,
@@ -613,7 +619,32 @@ fetch_base_func(const char **filename,
                 apr_pool_t *result_pool,
                 apr_pool_t *scratch_pool)
 {
-  *filename = NULL;
+  struct fetch_baton *fb = baton;
+  svn_stream_t *fstream;
+  svn_error_t *err;
+
+  if (! SVN_IS_VALID_REVNUM(base_revision))
+    base_revision = fb->head;
+
+  SVN_ERR(svn_stream_open_unique(&fstream, filename, NULL,
+                                 svn_io_file_del_on_pool_cleanup,
+                                 result_pool, scratch_pool));
+
+  err = svn_ra_get_file(fb->session, path, base_revision, fstream, NULL, NULL,
+                         scratch_pool);
+  if (err && err->apr_err == SVN_ERR_FS_NOT_FOUND)
+    {
+      svn_error_clear(err);
+      SVN_ERR(svn_stream_close(fstream));
+
+      *filename = NULL;
+      return SVN_NO_ERROR;
+    }
+  else if (err)
+    return svn_error_trace(err);
+
+  SVN_ERR(svn_stream_close(fstream));
+
   return SVN_NO_ERROR;
 }
 
@@ -625,7 +656,37 @@ fetch_props_func(apr_hash_t **props,
                  apr_pool_t *result_pool,
                  apr_pool_t *scratch_pool)
 {
-  *props = apr_hash_make(result_pool);
+  struct fetch_baton *fb = baton;
+  svn_node_kind_t node_kind;
+
+  if (! SVN_IS_VALID_REVNUM(base_revision))
+    base_revision = fb->head;
+
+  SVN_ERR(svn_ra_check_path(fb->session, path, base_revision, &node_kind,
+                            scratch_pool));
+
+  if (node_kind == svn_node_file)
+    {
+      SVN_ERR(svn_ra_get_file(fb->session, path, base_revision, NULL, NULL,
+                              props, result_pool));
+    }
+  else if (node_kind == svn_node_dir)
+    {
+      apr_array_header_t *tmp_props;
+
+      SVN_ERR(svn_ra_get_dir2(fb->session, NULL, NULL, props, path,
+                              base_revision, 0 /* Dirent fields */,
+                              result_pool));
+      tmp_props = svn_prop_hash_to_array(*props, result_pool);
+      SVN_ERR(svn_categorize_props(tmp_props, NULL, NULL, &tmp_props,
+                                   result_pool));
+      *props = svn_prop_array_to_hash(tmp_props, result_pool);
+    }
+  else
+    {
+      *props = apr_hash_make(result_pool);
+    }
+
   return SVN_NO_ERROR;
 }
 
@@ -636,19 +697,36 @@ fetch_kind_func(svn_kind_t *kind,
                 svn_revnum_t base_revision,
                 apr_pool_t *scratch_pool)
 {
-  *kind = svn_kind_unknown;
+  struct fetch_baton *fb = baton;
+  svn_node_kind_t node_kind;
+
+  if (! SVN_IS_VALID_REVNUM(base_revision))
+    base_revision = fb->head;
+
+  SVN_ERR(svn_ra_check_path(fb->session, path, base_revision, &node_kind,
+                             scratch_pool));
+
+  *kind = svn__kind_from_node_kind(node_kind, FALSE);
+
   return SVN_NO_ERROR;
 }
 
 static svn_delta_shim_callbacks_t *
-get_shim_callbacks(apr_pool_t *result_pool)
+get_shim_callbacks(svn_ra_session_t *session,
+                   svn_revnum_t head,
+                   apr_pool_t *result_pool)
 {
   svn_delta_shim_callbacks_t *callbacks =
                             svn_delta_shim_callbacks_default(result_pool);
+  struct fetch_baton *fb = apr_pcalloc(result_pool, sizeof(*fb));
+
+  fb->session = session;
+  fb->head = head;
 
   callbacks->fetch_props_func = fetch_props_func;
   callbacks->fetch_kind_func = fetch_kind_func;
   callbacks->fetch_base_func = fetch_base_func;
+  callbacks->fetch_baton = fb;
 
   return callbacks;
 }
@@ -667,6 +745,8 @@ execute(const apr_array_header_t *action
         apr_pool_t *pool)
 {
   svn_ra_session_t *session;
+  svn_ra_session_t *aux_session;
+  const char *repos_root;
   svn_revnum_t head;
   const svn_delta_editor_t *editor;
   svn_ra_callbacks2_t *ra_callbacks;
@@ -687,6 +767,10 @@ execute(const apr_array_header_t *action
                               pool));
   SVN_ERR(svn_ra_open4(&session, NULL, anchor, NULL, ra_callbacks,
                        NULL, config, pool));
+  SVN_ERR(svn_ra_open4(&aux_session, NULL, anchor, NULL, ra_callbacks,
+                       NULL, config, pool));
+  SVN_ERR(svn_ra_get_repos_root2(aux_session, &repos_root, pool));
+  SVN_ERR(svn_ra_reparent(aux_session, repos_root, pool));
 
   SVN_ERR(svn_ra_get_latest_revnum(session, &head, pool));
   if (SVN_IS_VALID_REVNUM(base_revision))
@@ -757,7 +841,7 @@ execute(const apr_array_header_t *action
     }
 
   SVN_ERR(svn_ra__register_editor_shim_callbacks(session,
-                                                 get_shim_callbacks(pool)));
+                            get_shim_callbacks(aux_session, head, pool)));
   SVN_ERR(svn_ra_get_commit_editor3(session, &editor, &editor_baton, revprops,
                                     commit_callback, NULL, NULL, FALSE, pool));
 



Mime
View raw message