You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Yoshiki Hayashi <yo...@xemacs.org> on 2001/11/29 13:14:11 UTC

[PATCH] make get_func optional in ra_dav get_commit_editor

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

Re: [PATCH] make get_func optional in ra_dav get_commit_editor

Posted by cm...@collab.net.
Yoshiki Hayashi <yo...@xemacs.org> writes:

> 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.

committed.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] make get_func optional in ra_dav get_commit_editor

Posted by cm...@collab.net.
Yoshiki Hayashi <yo...@xemacs.org> writes:

> > I'm pretty sure I busted that code all the heck yesterday.
> > Sorry for any inconveniences, and I'll definitely be
> > reviewing your patch immediately.
> 
> No, you didn't cause any inconveniences.  libsvn_wc always
> passes get_func so the only real application which does not
> provide get_func is my Ruby script. :-)
> 
> It just happend to be the part of code I was modifying and
> I've been bitten earlier.  Thank you very much for reviewing
> so quickly.

No, actually we don't provide a get_func when we...

   svn rm REPOS_URL
   svn mkdir REPOS_URL
   svn copy WC_PATH REPOS_URL
   svn copy REPOS_URL REPOS_URL
   svn move REPOS_URL REPOS_URL

...and perhaps other things in the future.  Those are just the ones I
can remember off the top of my (sleepy) head.

So yeah, plenty of use cases.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] make get_func optional in ra_dav get_commit_editor

Posted by Yoshiki Hayashi <yo...@xemacs.org>.
cmpilato@collab.net writes:

> I'm pretty sure I busted that code all the heck yesterday.
> Sorry for any inconveniences, and I'll definitely be
> reviewing your patch immediately.

No, you didn't cause any inconveniences.  libsvn_wc always
passes get_func so the only real application which does not
provide get_func is my Ruby script. :-)

It just happend to be the part of code I was modifying and
I've been bitten earlier.  Thank you very much for reviewing
so quickly.

-- 
Yoshiki Hayashi

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] make get_func optional in ra_dav get_commit_editor

Posted by cm...@collab.net.
Yoshiki Hayashi <yo...@xemacs.org> writes:

> 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.

Oh crap.  While I could just wait for Greg S. to join me in the office
here in a few minutes, I'll just go ahead and publicly admit to him
(and to all) my level of suck.  I'm pretty sure I busted that code all
the heck yesterday.  Sorry for any inconveniences, and I'll definitely
be reviewing your patch immediately.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org