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

Re: [PATCH] Moving/copying added files and dirs

From: Paul Burba <paulb_at_softlanding.com>
Date: 2006-08-09 15:44:53 CEST

rooneg@gmail.com wrote on 08/08/2006 03:03:20 PM:

> On 8/8/06, Ivan Zhakov <chemodax@gmail.com> wrote:
>
> > Second problem in setup_copy():
> > if (!src_is_url)
> > {
> > /* Are we copying/moving a path that is scheduled for addition?
*/
> > SVN_ERR(svn_wc_adm_probe_open3(&adm_access, NULL, src_path,
FALSE, 0,
> > ctx->cancel_func,
ctx->cancel_baton,
> > pool));
> > SVN_ERR(svn_wc_entry(&entry, src_path, adm_access, FALSE,
pool));
> > SVN_ERR(svn_wc_adm_close(adm_access));
> > src_is_add = (entry && entry->revision == 0) ? TRUE : FALSE;
> > }
> > Might be I forget something, but AFAIK zero revision number is valid.
> > So you should check against SVN_INVALID_REVNUM or check url field. I
> > don't remember exactly.
>
> Well, 0 is a valid revision, but it'll only ever exist on the root of
> the repos, so it's not something you can actually copy...

Hi All,

Just to be clear on my goal in this chunk of code: it's to determine if
the src_path arg to setup_copy is scheduled for addition as a result of
svn add, as opposed to a WC->WC copy/move. We need to know this since
wc_to_wc_copy() handles these two cases differently. My comment is
unclear on this and I will improve it with something like this:

   if (!src_is_url)
     {
       /* Are we copying/moving a path that is scheduled for addition
          as the result of svn add or svn mv/cp? */
       SVN_ERR(svn_wc_adm_probe_open3(&adm_access, NULL, src_path, FALSE,
0,
                                      ctx->cancel_func, ctx->cancel_baton,
                                      pool));

Anyway, how do we differentiate between these two scenarios? Comparing
entry fields for each:

ENTRY ADDED WC->WC
FIELD FILE COPIED/MOVED
                             FILE
----------- ----- ------------
name upsilon alpha_copied
kind file
revision 0
url
repos
schedule add add
text-time
checksum d1fa4a3ced98961674a441930a51f2d3
committed-date
committed-rev
last-author
has-props
has-prop-mods
cachable-props
present-props
conflict-old
conflict-new
conflict-wrk
prop-reject-file
copied copied
comyfrom-url
http://localhost/svn-test-work/repositories/copy_tests-1/A/B/E/alpha
copyfrom-rev 1
deleted
absent
incomplete
uuid
lock-token
lock-owner
lock-comment
lock-creation-date

(A copied/moved directory entry differs only in that it has no checksum)

So we can't just look at the schedule value, it's add in both cases. The
explanation of the revision field in
http://svn.collab.net/repos/svn/trunk/subversion/libsvn_wc/README is:

revision:
   The revision that the pristine text and properties of this entry
   represent. Defaults to the revision of the this_dir entry, for
   which it is required. Set to 0 for entries not yet in the
   repository.

Between this and the observed behavior above led me to think that looking
at the rev is the way to differentiate between the two scenarios. The
docstring for svn_wc_add2() makes no promises regarding the revision of
added paths, though it does explicitly set it to 0 on line 1184:

tmp_entry.revision = 0;

Maybe I'm making a dangerous assumption?

Perhaps it's better to look at the schedule *and* copy fields to make the
determination?

   if (!src_is_url)
     {
       /* Are we copying/moving a path that is scheduled for addition
          as the result of svn add or svn mv/cp? */
       SVN_ERR(svn_wc_adm_probe_open3(&adm_access, NULL, src_path, FALSE,
0,
                                      ctx->cancel_func, ctx->cancel_baton,
                                      pool));
       SVN_ERR(svn_wc_entry(&entry, src_path, adm_access, FALSE, pool));
       SVN_ERR(svn_wc_adm_close(adm_access));
       /* If scheduled for addition but not copied, src_path is
          result of svn add not svn cp/mv. */
       src_is_add = (entry
                     && entry->schedule == svn_wc_schedule_add
                     && !(entry->copied))
                     ? TRUE : FALSE;
     }

Thoughts?

Paul B.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Aug 9 15:45:52 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.