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

Re: svn commit: rev 2181 - trunk/subversion/tests/clients/cmdline trunk/subversion/tests/clients/cmdline/svntest

From: Greg Stein <gstein_at_lyra.org>
Date: 2002-06-15 01:40:35 CEST

On Thu, Jun 13, 2002 at 01:11:31PM +0100, Philip Martin wrote:
> Greg Stein <gstein@lyra.org> writes:
>...
> > But it is a start... comments?
>
> One jumps out.
>
> The state objects operate with "Subversion paths" like 'A/D/G/rho' but
> "OS paths" like os.path_join(wc_dir, 'A', 'D', 'G', 'rho') are
> required for svntest.actions and for working copy manipulations. Your

Well... "required" isn't strictly true :-)

When I was converting the code, I noticed the mixing of path styles. In
particular, look at line 79 of actions.py (thanks also to Ben for pointing
out the specific case). We took the '/'-separated paths of main.greek_tree
and combined them with directories.

And it all seems to work... My assumption is that Windows is allowing
forward-slashes (which I believe that I've heard people mention is okay).

Now... *should* it ever pose a problem, then we can easily have a State
object return a proper path for us. It could take its .wc_dir attribute and
join that with a path. For example:

  def os_path(self, *parts):
    args = [ self.wc_dir ]
    for part in parts:
      args.extend(string.split(part, '/'))
    return apply(os.path.join, args)

This allows constructs like:

  state.os_path('A')
  state.os_path('A/D')
  state.os_path('A', 'D')
  state.os_path('A/D', 'G/rho')

>...
> I would like to be able to construct OS paths from Subversion
> paths. Then I could write things like
>
> G_path = 'A/D/G'
> rho_path = G_path + '/rho'
> svntest.main.file_append(xxxx(wc_dir, rho_path), 'some text')
> svntest.main.run_svn(None, 'rm', xxxx(wc_dir, G_path))
> svntest.main.run_svn(None, 'rm', '--force', xxxx(wc_dir, G_path))
> expected_status.tweak_one(G_path, status='D ')
> expected_status.tweak_one(rho_path, status='D ')
> shutil.rmtree(xxxx(wc_dir, G_path))

The above would have lines like:

  svntest.main.file_append(expected_status.os_path(rho_path), 'some text')

Hmm. Just thought of something. If wc.State() represents a working copy,
then we could do things like:

  state.run_svn(...)

To have operations performed on items in the working copy referenced by the
State. Of course, we just paths arbitrary paths to 'svn', and it operates on
the appropriate WC, so maybe this is no big deal...

> xxxx is some function (or method, or operator, or whatever) that
> converts
>
> (wc_dir, G_path, '/rho')
>
> into
>
> (os.path.join(wc_dir, 'A', 'D', 'G', 'rho'))
>
> I think I would require the first argument to be an OS path, and all
> subsequent arguments to be Subversion paths.

Well, a State object is already rooted at a wc_dir, so it would be handy for
these types of conversions.

Another alternative is to have the Sandbox object do it. Note that most of
the tests do:

  wc_dir = sbox.wc_dir

It would be quite reasonable to do:

  sbox.os_path('A', 'D')

etc.

I think it really depends on which method the .os_path makes the most sense.
I first started thinking about the State object, but the Sandbox might be
more appropriate.

Summary for comments:

* forward-slash seems to work fine on Windows
* does the .os_path() seem to make sense?
* should .os_path go on the Sandbox? Or on a State? Both? Maybe just a
  function in svntest.main?

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Jun 15 01:39:22 2002

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