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

Re: Ben, question about adm_ops.c:svn_wc_revert

From: <cmpilato_at_collab.net>
Date: 2002-01-25 08:24:32 CET

First off, I wrote that code, so let's not expect Ben to know what the
intention was there. :-)

> svn_wc_revert() has this code:
>
> [...]
> /* Determine if PATH is a WC root. If PATH is a file, it should
> definitely NOT be a WC root. */
> SVN_ERR (svn_wc_is_wc_root (&wc_root, path, pool));
> if (! wc_root)
> {
> /* Split the basename from the parent path. */
> svn_path_split (path, &p_dir, &bname, pool);
> if (svn_path_is_empty (p_dir))
> p_dir = svn_stringbuf_create (".", pool);
> }
> [...]
>
> Based on how `wc_root' is used there and later on, I'm wondering if a
> svn_wc_is_wc_root() is the real question the code wants to ask?
> Aren't we just trying to find out if `path' is a file or directory,
> and if file, do some things that are specific to reverting files?

No, that's not "real question." Older versions of this function asked
that question, then I determined that "is this a dir?" is the wrong
question, and "is this a wc root?" the right one. Now, if only I
could remember why...

Ah yes, reading the code helps. Further down in the function, we see:

      /* Reset the schedule to normal. */
      if (! wc_root)
        {
          if (modify_flags & SVN_WC__ENTRY_MODIFY_ATTRIBUTES)
            {
              /* This *should* be the removal of the .rej and .prej
                 directives. */
              remove1 = SVN_WC_ENTRY_ATTR_REJFILE;
              remove2 = SVN_WC_ENTRY_ATTR_PREJFILE;
            }

          SVN_ERR (svn_wc__entry_modify
                   (p_dir,
                    bname,
                    modify_flags | SVN_WC__ENTRY_MODIFY_FORCE,
                    SVN_INVALID_REVNUM,
                    entry->kind,
                    svn_wc_schedule_normal,
                    entry->conflicted,
                    entry->copied,
                    entry->text_time,
                    entry->prop_time,
                    NULL, entry->attributes,
                    pool,
                    remove1,
                    remove2,
                    NULL));
        }

This portion of code is exactly on the parent of the revert target,
which is a valid thing to do only if the revert target is not a WC
root. Why? Because by definition a WC root is either '.' (which you
really shouldn't be reverting while your inside of it) or a directory
that is disjoint with respect to its parent in the working copy,
meaning its parent has no entry for the target of the revert (and
therefore, we can't exactly update that non-existent entry).

> (Whereas if it's to remain public, it probably doesn't belong in
> get_editor.c, but maybe in questions.c or something?)

Yeah, I'm cool wit' dat.

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