[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] make get_func optional in ra_dav get_commit_editor

From: Yoshiki Hayashi <yoshiki_at_xemacs.org>
Date: 2001-11-29 14:14:11 CET

This patch allows you to commit files without providing
get_func. Current code will lose information because it
will succeed to commit even when it should result in
conflict. It should version_url according to revision,
which is not always the latest revision.

My losssage in commit happened the same way because somehow
I mistyped and the code always used rsrc->url instead of the
URL based on the baseline collection.

Probably created flag in add_child can be removed because
revision is valid => created is false
revision is invalid => created is true
but I wanted to post this first to see whether this patch
is the right approach.

* commit.c

(get_version_url): Take revision as argument. Returns the
  property of the latest revision when revision is invalid.
  Otherwise, get the property of specified revision.

(add_child): Take revision as argument and pass it to
  get_version_url.

(commit_open_root): Pass SVN_INVALID_REVNUM to get_version_url.
(commit_add_dir): Pass SVN_INVALID_REVNUM to add_child.
(commit_open_dir): Pass base_revision to add_child.
(commit_add_file): Pass SVN_INVALID_REVNUM to add_child.
(commit_open_file): Pass base_revision to add_child.

Index: ./subversion/libsvn_ra_dav/commit.c
===================================================================
--- ./subversion/libsvn_ra_dav/.svn/text-base/commit.c.svn-base Thu Nov 29 15:56:53 2001
+++ ./subversion/libsvn_ra_dav/commit.c Thu Nov 29 16:15:00 2001
@@ -179,9 +179,11 @@
   return NULL;
 }
 
-static svn_error_t * get_version_url(commit_ctx_t *cc, resource_t *rsrc)
+static svn_error_t * get_version_url(commit_ctx_t *cc, resource_t *rsrc,
+ svn_revnum_t revision)
 {
   svn_ra_dav_resource_t *propres;
+ const char *url;
 
   if (cc->get_func != NULL)
     {
@@ -197,8 +199,31 @@
 
       /* whoops. it wasn't there. go grab it from the server. */
     }
-
- SVN_ERR( svn_ra_dav__get_props_resource(&propres, cc->ras->sess, rsrc->url,
+
+ if (revision == SVN_INVALID_REVNUM)
+ url = rsrc->url;
+ else
+ {
+ svn_string_t bc_url, bc_relative;
+ svn_stringbuf_t *bc;
+
+ SVN_ERR( svn_ra_dav__get_baseline_info(NULL,
+ &bc_url, &bc_relative, NULL,
+ cc->ras->sess,
+ rsrc->url,
+ revision,
+ cc->ras->pool));
+ bc = svn_stringbuf_create(bc_url.data, cc->ras->pool);
+ svn_path_add_component_nts(bc, bc_relative.data,
+ svn_path_url_style);
+
+ SVN_ERR( svn_ra_dav__get_props_resource(&propres, cc->ras->sess,
+ bc->data, NULL, fetch_props,
+ cc->ras->pool) );
+ url = bc->data;
+ }
+
+ SVN_ERR( svn_ra_dav__get_props_resource(&propres, cc->ras->sess, url,
                                           NULL, fetch_props, cc->ras->pool) );
   rsrc->vsn_url = apr_hash_get(propres->propset,
                                SVN_RA_DAV__PROP_CHECKED_IN,
@@ -287,7 +312,8 @@
                                commit_ctx_t *cc,
                                const resource_t *parent,
                                const char *name,
- int created)
+ int created,
+ svn_revnum_t revision)
 {
   apr_pool_t *pool = cc->ras->pool;
   resource_t *rsrc;
@@ -313,9 +339,7 @@
      This means it has a VR URL already, and the WR URL won't exist
      until it's "checked out". */
   else
- {
- SVN_ERR( get_version_url(cc, rsrc) );
- }
+ SVN_ERR( get_version_url(cc, rsrc, revision) );
 
   apr_hash_set(cc->resources, rsrc->url, APR_HASH_KEY_STRING, rsrc);
 
@@ -548,7 +572,7 @@
   /* ### should we use the WC symbol? (SVN_WC_ENTRY_THIS_DIR) */
   rsrc->local_path = svn_stringbuf_create("", cc->ras->pool);
 
- SVN_ERR( get_version_url(cc, rsrc) );
+ SVN_ERR( get_version_url(cc, rsrc, SVN_INVALID_REVNUM) );
 
   apr_hash_set(cc->resources, rsrc->url, APR_HASH_KEY_STRING, rsrc);
 
@@ -619,7 +643,8 @@
   /* create a child object that contains all the resource urls */
   child = apr_pcalloc(pool, sizeof(*child));
   child->cc = parent->cc;
- SVN_ERR( add_child(&child->rsrc, parent->cc, parent->rsrc, name->data, 1) );
+ SVN_ERR( add_child(&child->rsrc, parent->cc, parent->rsrc,
+ name->data, 1, SVN_INVALID_REVNUM) );
 
   if (! copyfrom_path)
     {
@@ -692,7 +717,8 @@
   resource_baton_t *child = apr_pcalloc(pool, sizeof(*child));
 
   child->cc = parent->cc;
- SVN_ERR( add_child(&child->rsrc, parent->cc, parent->rsrc, name->data, 0) );
+ SVN_ERR( add_child(&child->rsrc, parent->cc, parent->rsrc,
+ name->data, 0, base_revision) );
 
   /*
   ** Note: open_dir simply means that a change has occurred somewhere
@@ -761,7 +787,8 @@
   /* Construct a file_baton that contains all the resource urls. */
   file = apr_pcalloc(pool, sizeof(*file));
   file->cc = parent->cc;
- SVN_ERR( add_child(&file->rsrc, parent->cc, parent->rsrc, name->data, 1) );
+ SVN_ERR( add_child(&file->rsrc, parent->cc, parent->rsrc,
+ name->data, 1, SVN_INVALID_REVNUM) );
 
   if (! copyfrom_path)
     {
@@ -831,7 +858,8 @@
 
   file = apr_pcalloc(pool, sizeof(*file));
   file->cc = parent->cc;
- SVN_ERR( add_child(&file->rsrc, parent->cc, parent->rsrc, name->data, 0) );
+ SVN_ERR( add_child(&file->rsrc, parent->cc, parent->rsrc,
+ name->data, 0, base_revision) );
 
   /* do the CHECKOUT now. we'll PUT the new file contents later on. */
   SVN_ERR( checkout_resource(parent->cc, file->rsrc) );

-- 
Yoshiki Hayashi
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:36:49 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.