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

Re: Python question

From: Branko Čibej <brane_at_xbc.nu>
Date: 2003-01-11 18:34:03 CET

Philip Martin wrote:

>I am writing a regression test involving 'svn status' and symbolic
>links in the working copy. I'm using os.symlink and I assume this
>won't work on Windows, so the the test is skipped:
> Skip(status_type_change_to_link, (os.name != 'posix')),
>The problem I am having is the function chmod_tree in svntest/main.py.
>This gets run at the start of the test as part of removing any old
>working copy from a previous run. It doesn't work when it encounters
>symbolic links that point to items that don't exist. So far the only
>way I can make this work is
>Index: ../svn/subversion/tests/clients/cmdline/svntest/main.py
>--- ../svn/subversion/tests/clients/cmdline/svntest/main.py (revision 4346)
>+++ ../svn/subversion/tests/clients/cmdline/svntest/main.py (working copy)
>@@ -243,8 +243,12 @@
> mode, mask = arg
> for name in names:
> fullname = os.path.join(dirname, name)
>- new_mode = (os.stat(fullname)[stat.ST_MODE] & ~mask) | mode
>- os.chmod(fullname, new_mode)
>+ try:
>+ new_mode = (os.stat(fullname)[stat.ST_MODE] & ~mask) | mode
>+ os.chmod(fullname, new_mode)
>+ except OSError:
>+ # Ugly, but this happens for a broken symbolic link
>+ pass
> os.path.walk(path, visit, (mode, mask))
> # For clearing away working copies
>Anyone got any better ideas?

I think this is acceptable. You do describe what's happening, and why
the OSError is ignored. In certain weird cases the shutil.rmtree might
fail later on, but I don't expect to see such cases until people start
putting fifos and other weirdness in the test dirs.

Brane Čibej   <brane_at_xbc.nu>   http://www.xbc.nu/brane/
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Jan 11 18:34:47 2003

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.