You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by cm...@apache.org on 2011/05/05 22:26:37 UTC
svn commit: r1099958 - /subversion/trunk/subversion/libsvn_ra_neon/commit.c
Author: cmpilato
Date: Thu May 5 20:26:36 2011
New Revision: 1099958
URL: http://svn.apache.org/viewvc?rev=1099958&view=rev
Log:
Abstract some nearly-identical code bits into a helper function.
* subversion/libsvn_ra_neon/commit.c
(copy_resource): New helper function, abstracted from code all too
common between...
(commit_add_dir, commit_add_file): ...these two functions, which now
just use copy_resource().
Modified:
subversion/trunk/subversion/libsvn_ra_neon/commit.c
Modified: subversion/trunk/subversion/libsvn_ra_neon/commit.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_neon/commit.c?rev=1099958&r1=1099957&r2=1099958&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_neon/commit.c (original)
+++ subversion/trunk/subversion/libsvn_ra_neon/commit.c Thu May 5 20:26:36 2011
@@ -553,6 +553,43 @@ static void record_prop_change(apr_pool_
}
}
+/* Send a Neon COPY request to the location identified by
+ COPYFROM_PATH and COPYFROM_REVISION, using COPY_DST_URL as the
+ "Destination" of that copy. */
+static svn_error_t *copy_resource(svn_ra_neon__session_t *ras,
+ const char *copyfrom_path,
+ svn_revnum_t copyfrom_revision,
+ const char *copy_dst_url,
+ svn_boolean_t is_dir,
+ apr_pool_t *scratch_pool)
+{
+ svn_string_t bc_url, bc_relative;
+ const char *copy_src_url;
+
+ /* Convert the copyfrom_* url/rev "public" pair into a Baseline
+ Collection (BC) URL that represents the revision -- and a
+ relative path under that BC. */
+ SVN_ERR(svn_ra_neon__get_baseline_info(NULL, &bc_url, &bc_relative, NULL,
+ ras, copyfrom_path,
+ copyfrom_revision, scratch_pool));
+
+ /* Combine the BC-URL and relative path; this is the main
+ "source" argument to the COPY request. The "Destination:"
+ header given to COPY is simply the wr_url that is already
+ part of the file_baton. */
+ copy_src_url = svn_path_url_add_component2(bc_url.data,
+ bc_relative.data,
+ scratch_pool);
+
+ /* Have neon do the COPY. */
+ SVN_ERR(svn_ra_neon__copy(ras, 1 /* overwrite */,
+ is_dir ? SVN_RA_NEON__DEPTH_INFINITE
+ : SVN_RA_NEON__DEPTH_ZERO,
+ copy_src_url, copy_dst_url, scratch_pool));
+
+ return SVN_NO_ERROR;
+}
+
/*
A very long note about enforcing directory-up-to-dateness when
proppatching, writ by Ben:
@@ -834,7 +871,6 @@ static svn_error_t * commit_delete_entry
}
-
static svn_error_t * commit_add_dir(const char *path,
void *parent_baton,
const char *copyfrom_path,
@@ -873,37 +909,9 @@ static svn_error_t * commit_add_dir(cons
}
else
{
- svn_string_t bc_url, bc_relative;
- const char *copy_src;
-
/* This add has history, so we need to do a COPY. */
-
- /* Convert the copyfrom_* url/rev "public" pair into a Baseline
- Collection (BC) URL that represents the revision -- and a
- relative path under that BC. */
- SVN_ERR(svn_ra_neon__get_baseline_info(NULL,
- &bc_url, &bc_relative, NULL,
- parent->cc->ras,
- copyfrom_path,
- copyfrom_revision,
- workpool));
-
-
- /* Combine the BC-URL and relative path; this is the main
- "source" argument to the COPY request. The "Destination:"
- header given to COPY is simply the wr_url that is already
- part of the child object. */
- copy_src = svn_path_url_add_component2(bc_url.data,
- bc_relative.data,
- workpool);
-
- /* Have neon do the COPY. */
- SVN_ERR(svn_ra_neon__copy(parent->cc->ras,
- 1, /* overwrite */
- SVN_RA_NEON__DEPTH_INFINITE, /* deep copy */
- copy_src, /* source URI */
- child->rsrc->wr_url, /* dest URI */
- workpool));
+ SVN_ERR(copy_resource(parent->cc->ras, copyfrom_path, copyfrom_revision,
+ child->rsrc->wr_url, TRUE, workpool));
/* Remember that this object was copied. */
child->copied = TRUE;
@@ -1074,38 +1082,9 @@ static svn_error_t * commit_add_file(con
}
else
{
- svn_string_t bc_url, bc_relative;
- const char *copy_src;
-
/* This add has history, so we need to do a COPY. */
-
- /* Convert the copyfrom_* url/rev "public" pair into a Baseline
- Collection (BC) URL that represents the revision -- and a
- relative path under that BC. */
- SVN_ERR(svn_ra_neon__get_baseline_info(NULL,
- &bc_url, &bc_relative, NULL,
- parent->cc->ras,
- copyfrom_path,
- copyfrom_revision,
- workpool));
-
-
- /* Combine the BC-URL and relative path; this is the main
- "source" argument to the COPY request. The "Destination:"
- header given to COPY is simply the wr_url that is already
- part of the file_baton. */
- copy_src = svn_path_url_add_component2(bc_url.data,
- bc_relative.data,
- workpool);
-
- /* Have neon do the COPY. */
- SVN_ERR(svn_ra_neon__copy(parent->cc->ras,
- 1, /* overwrite */
- SVN_RA_NEON__DEPTH_ZERO,
- /* file: this doesn't matter */
- copy_src, /* source URI */
- file->rsrc->wr_url,/* dest URI */
- workpool));
+ SVN_ERR(copy_resource(parent->cc->ras, copyfrom_path, copyfrom_revision,
+ file->rsrc->wr_url, FALSE, workpool));
/* Remember that this object was copied. */
file->copied = TRUE;
Re: svn commit: r1099958 - /subversion/trunk/subversion/libsvn_ra_neon/commit.c
Posted by "C. Michael Pilato" <cm...@collab.net>.
On 05/05/2011 05:54 PM, Greg Stein wrote:
> On Thu, May 5, 2011 at 16:26, <cm...@apache.org> wrote:
>> ...
>> +++ subversion/trunk/subversion/libsvn_ra_neon/commit.c Thu May 5 20:26:36 2011
>> ...
>> +static svn_error_t *copy_resource(svn_ra_neon__session_t *ras,
>> + const char *copyfrom_path,
>> + svn_revnum_t copyfrom_revision,
>> + const char *copy_dst_url,
>> + svn_boolean_t is_dir,
>> + apr_pool_t *scratch_pool)
>> +{
>> ...
>> + /* Have neon do the COPY. */
>> + SVN_ERR(svn_ra_neon__copy(ras, 1 /* overwrite */,
>> + is_dir ? SVN_RA_NEON__DEPTH_INFINITE
>> + : SVN_RA_NEON__DEPTH_ZERO,
>> + copy_src_url, copy_dst_url, scratch_pool));
>
> If the depth is ignored for files, then why not just always pass
> INFINITE and be done with it?
That was on my "double-check this later" list. :-) I'm still working in
this code, and first-pass was intended to make no logical changes. But your
question validates my own line of thought here, so thanks!
--
C. Michael Pilato <cm...@collab.net>
CollabNet <> www.collab.net <> Distributed Development On Demand
Re: svn commit: r1099958 - /subversion/trunk/subversion/libsvn_ra_neon/commit.c
Posted by Greg Stein <gs...@gmail.com>.
On Thu, May 5, 2011 at 16:26, <cm...@apache.org> wrote:
>...
> +++ subversion/trunk/subversion/libsvn_ra_neon/commit.c Thu May 5 20:26:36 2011
>...
> +static svn_error_t *copy_resource(svn_ra_neon__session_t *ras,
> + const char *copyfrom_path,
> + svn_revnum_t copyfrom_revision,
> + const char *copy_dst_url,
> + svn_boolean_t is_dir,
> + apr_pool_t *scratch_pool)
> +{
>...
> + /* Have neon do the COPY. */
> + SVN_ERR(svn_ra_neon__copy(ras, 1 /* overwrite */,
> + is_dir ? SVN_RA_NEON__DEPTH_INFINITE
> + : SVN_RA_NEON__DEPTH_ZERO,
> + copy_src_url, copy_dst_url, scratch_pool));
If the depth is ignored for files, then why not just always pass
INFINITE and be done with it?
>...
Cheers,
-g