You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by cm...@collab.net on 2001/11/19 18:07:08 UTC

RA existence check?

Looking at this basic plan for performing copies:

   if (not exist src_path)
     return ERR_BAD_SRC error
   if (exist dst_path)
     {
       if (dst_path is directory)
         copy src_path into dst_path as basename (src_path)
       else
         return ERR_OBSTRUCTION error
     }
   else
     {
       if (not exist parent_of_dst_path)
         return ERR_BAD_DST error
       else
         copy src_path into parent_of_dst_path as basename (dst_path)
     }
   if (this is a move)
     delete src_path

An RA-layer existence/node-kind check of some sort is necessary.
You know, maybe something like:

   ra->get_node_kind (enum svn_node_kind *kind,
                      svn_string_t *url,
                      svn_revnum_t revision,
                      apr_pool_t *pool);

Where a node kind of svn_node_none would indicate non-existence.
GregS, is there an efficient way to do this in RA_DAV, or are we
talking about a custom REPORT/response couplet here?

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

Re: RA existence check?

Posted by Ben Collins-Sussman <su...@collab.net>.
cmpilato@collab.net writes:

> An RA-layer existence/node-kind check of some sort is necessary.
> You know, maybe something like:
> 
>    ra->get_node_kind (enum svn_node_kind *kind,
>                       svn_string_t *url,
>                       svn_revnum_t revision,
>                       apr_pool_t *pool);
> 
> Where a node kind of svn_node_none would indicate non-existence.
> GregS, is there an efficient way to do this in RA_DAV, or are we
> talking about a custom REPORT/response couplet here?

It's worse than you think;  there doesn't seem to be any way to to do
an existence ('stat') check in the public libsvn_fs API.  I discovered
this a couple of weeks ago when fiddling with the svnadmin shell.  My
hack was to do:

   if ((! svn_fs_is_dir) && (! svn_fs_is_file))

So maybe while you're at it, Mike, you can add this missing stat func
to svn_fs.h?  :-)

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

Re: RA existence check?

Posted by Ben Collins-Sussman <su...@collab.net>.
"Bill Tutt" <ra...@lyra.org> writes:

> You want to be careful when you use this kind of check, esp. from a
> ra_dav POV. You're usually much better off documenting, and checking
> against a remote non-existence error than having an additional round
> trip just to give a prettier error message. 

But in Mike's case, I'm not sure there's anything we can do.

I mean, suppose the user types:

   % svn cp A/mu http://foo/bar/baz

We've decided that this command causes an immediate commit of local
file 'mu' to the repository.  That means that the commit-editor needs
to be driven in a specific way.

But how do we drive the editor?

  - If baz is a directory, then we want to 

          open_dir(bar)
          open_dir(baz)
          add_file(mu)
          apply_txdelta(contents of mu)

  - If baz does not exist, then we want to

          open_dir(bar)
          add_file(baz)
          apply_txdelta(contents of mu)

  - If baz is already a file, then we either want to overwrite it, or
    possibly return an error.

          open_dir(bar)
          open_file(baz)
          appl_txdelta(contents of mu)


So really, I don't know how we can avoid doing an extra network 'stat'
of baz on the server; the answer completely determines how we should
drive the editor.


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

RE: RE: RA existence check?

Posted by Bill Tutt <ra...@lyra.org>.
You want to be careful when you use this kind of check, esp. from a
ra_dav POV. You're usually much better off documenting, and checking
against a remote non-existence error than having an additional round
trip just to give a prettier error message. 

As the folks on the MS perf alias are found of saying:
   Design for performance. 

If you know that round trips are bad, try to minimize the need to add
extra ones, instead of having to go fix it up later....

Bill
--
Bunnies aren't just cute like everybody supposes.
They got their hoppy legs and twitchy little noses.
And what's with all the carrots, 
What do they need such good eyesight for anyway?


-----Original Message-----
From: Greg Stein [mailto:gstein@collab.net] 
Sent: Monday, November 19, 2001 11:30 AM
To: cmpilato@collab.net
Cc: dev@subversion.tigris.org
Subject: RE: RA existence check?

> -----Original Message-----
> From: cmpilato@collab.net [mailto:cmpilato@collab.net]
> Sent: Monday, November 19, 2001 10:07 AM
>...
> An RA-layer existence/node-kind check of some sort is necessary.
> You know, maybe something like:
>
>    ra->get_node_kind (enum svn_node_kind *kind,
>                       svn_string_t *url,
>                       svn_revnum_t revision,
>                       apr_pool_t *pool);
>
> Where a node kind of svn_node_none would indicate non-existence.
> GregS, is there an efficient way to do this in RA_DAV, or are we
> talking about a custom REPORT/response couplet here?

That is a PROPFIND (Depth:0) for the DAV:resourcetype property.

You can use the svn_ra_dav__get_one_prop() function to fetch it. If the
PROPFIND fails with a 404, then you have svn_node_none. If the resulting
property looks like:

    <D:resourcetype>
      <D:collection/>
    </D:resourcetype>

Then it is a collection (directory; svn_node_dir). Otherwise, it is a
regular resource (svn_node_file).

The harder part is parsing the resourcetype property. "Proper" parsing
means
treating it as an XML property and looking for the DAV:collection
element in
there. To do that, however, means that get_one_prop() can't be used. I
think
there may be some Neon functions for parsing XML properties; we'd need
to
look. That would probably be the best approach. (an alternative is to
use
apr_xml_* parsing functions on the returned string; get back a DOM-like
thing, and look for the element).

Cheers,
-g


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



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

RE: RA existence check?

Posted by Greg Stein <gs...@collab.net>.
> -----Original Message-----
> From: cmpilato@collab.net [mailto:cmpilato@collab.net]
> Sent: Monday, November 19, 2001 10:07 AM
>...
> An RA-layer existence/node-kind check of some sort is necessary.
> You know, maybe something like:
>
>    ra->get_node_kind (enum svn_node_kind *kind,
>                       svn_string_t *url,
>                       svn_revnum_t revision,
>                       apr_pool_t *pool);
>
> Where a node kind of svn_node_none would indicate non-existence.
> GregS, is there an efficient way to do this in RA_DAV, or are we
> talking about a custom REPORT/response couplet here?

That is a PROPFIND (Depth:0) for the DAV:resourcetype property.

You can use the svn_ra_dav__get_one_prop() function to fetch it. If the
PROPFIND fails with a 404, then you have svn_node_none. If the resulting
property looks like:

    <D:resourcetype>
      <D:collection/>
    </D:resourcetype>

Then it is a collection (directory; svn_node_dir). Otherwise, it is a
regular resource (svn_node_file).

The harder part is parsing the resourcetype property. "Proper" parsing means
treating it as an XML property and looking for the DAV:collection element in
there. To do that, however, means that get_one_prop() can't be used. I think
there may be some Neon functions for parsing XML properties; we'd need to
look. That would probably be the best approach. (an alternative is to use
apr_xml_* parsing functions on the returned string; get back a DOM-like
thing, and look for the element).

Cheers,
-g


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