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

Re: svn info not setting exit status.

From: Mark E. Hamilton <mhamilt_at_sandia.gov>
Date: Tue, 20 May 2008 13:35:47 -0600

Henrik Sundberg wrote:
> 2008/5/20 Karl Fogel <kfogel_at_red-bean.com>:
>> [I'm cross-posting this to dev@, because the behavior might be a bug.]
>> "Mark E. Hamilton" <mhamilt_at_sandia.gov> writes:
>>> I'm trying to check to see if a path exists in my repository or
>>> not. However, when I use 'svn info' on an invalid URL it does not set
>>> the exit status to a non-zero value as I expected.
> Having the same need, and using pysvn I get:
> try:
> inf = client.info2("%s/%s" % (url, sf), recurse=False)
> except:
> client.mkdir("%s/%s" % (url, sf), "Setting up a root for %s" % sf)
> client.mkdir("%s/%s/branches" % (url, sf), "Adding branches")
> client.mkdir("%s/%s/tags" % (url, sf), "Adding tags")
> client.mkdir("%s/%s/trunk" % (url, sf), "Adding trunk")
> I though that was ugly, I wanted to say:
> if not client.is_url("%s/%s" % (url, sf)):
> client.mkdir("%s/%s" % (url, sf), "Setting up a root for %s" % sf)
> ...
> But that doesn't work, since is_url returns True if the first part of
> url matches a repository.
> In the shell you'll have to settle for return codes.
> Would it be better to have a special command, instead of using a side
> effect of the info-command?

I don't think a special command is necessary. I like the idea of
allowing the --quiet option for 'svn info', however, since all I'm doing
it testing for the existence (or non-existence) of something.

>> In order to make the multi-target behavior work, we decided that a
>> non-existent target shouldn't cause svn to bail out, but should instead
>> print a warning and then continue to the next target.
> <snip>
>> We definitely should continue the loop even in case of error, so we try
>> every target. But when we do exit, should it be a non-zero exit code if
>> any target received an error? Currently, we exit with zero.
> In the case of the OP there is only need to check one url a time.
> This ought to be a common need.
> If only one url is given and that one doesn't exist, then it ought to
> be ok with an error. Wouldn't it?
> This could be extended to: Fail if all targets are missing.

A single URL should be no different in this case than multiple URLs; all
should be tested, and if one or more causes a failure that failure (more
accurately the last failure) should be returned to the user, so he/she
can decide how to handle it.

Mark E. Hamilton
Orion International Technologies, Inc.
Sandia National Laboratory, NM.
To unsubscribe, e-mail: users-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: users-help_at_subversion.tigris.org
Received on 2008-05-20 21:36:31 CEST

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.