Discussion:
how to detect read-only branch from client?
Torsten Mueller
2017-02-13 16:50:32 UTC
Permalink
I write a script getting sources from one repository, doing a build and
other time consuming things and then committing the results into another
repsitory.

The problem is: the detination side is "managed" which means that I must
expect read only branches there. They use the path based authentication
feature (see VisualSVNServer) without any communication. They want to
close a branch for commits, that's enough communication.

But in my case it would be very bad to start a process which runs for an
hour or longer and then fails because it can't do the final commit.

How can I detect if a path in the destination directory is read only
without modifying it?

My first guess was to use "svnmucc propdel" to delete a property which
doesn't exist. This works great on a branch which is read only. But on
the other side it creates always a revision on normal branches. That's
not good. What can I do?

T.M.
Andrew Reedick
2017-02-14 17:32:06 UTC
Permalink
Not a complete solution, but it's a start. Craft a "svn mkdir" that includes the url to test and a url that will always fail, e.g.
svn mkdir -m "" http://server/repo/dir2test/a http://server/repo/readonly/z

However, it looks like the urls are sorted and then processed in sort order (including for svnmucc.) So you need your test url to come before your "will always fail" readonly url. Getting the sorting figured out is left an exercise to the reader. Maybe someone else knows of a way to ensure that the "always fail" readonly url gets checked last regardless of windows sorting, linux sorting, LC_ALL/LC_COLLATE settings, etc.


-----Original Message-----
From: Torsten Mueller [mailto:***@runbox.com]
Sent: Monday, February 13, 2017 11:51 AM
To: ***@subversion.apache.org
Subject: how to detect read-only branch from client?

I write a script getting sources from one repository, doing a build and other time consuming things and then committing the results into another repsitory.

The problem is: the detination side is "managed" which means that I must expect read only branches there. They use the path based authentication feature (see VisualSVNServer) without any communication. They want to close a branch for commits, that's enough communication.

But in my case it would be very bad to start a process which runs for an hour or longer and then fails because it can't do the final commit.

How can I detect if a path in the destination directory is read only without modifying it?

My first guess was to use "svnmucc propdel" to delete a property which doesn't exist. This works great on a branch which is read only. But on the other side it creates always a revision on normal branches. That's not good. What can I do?

T.M.
Torsten Mueller
2017-02-15 07:41:16 UTC
Permalink
Not a complete solution, but it's a start. Craft a "svn mkdir" that
includes the url to test and a url that will always fail
That's it. The key is to create a nested directory in a branch, this
means a directory which has a non-existing parent, and doing that
without the --parent parameter:

Test/ro is a readonly branch
Test/rw is a normal (read/write) branch

trying to create directory "a/b":

$ svn mkdir -m"xx" https://repository/svn/Binaries/Test/ro/a/b"
svn: E175013: Access to '/svn/Binaries/!svn/txr/50-1u/Test/ro/a/b' forbidden

$ svn mkdir -m"xx" https://repository/svn/Binaries/Test/rw/a/b"
svn: E160013: Try 'svn mkdir --parents' instead?
svn: E160013: File not found: transaction '50-1v', path '/Test/rw/a/b'

This gives two distiguishable messages: in the first case it fails
because of the readonly property, in the second case because of the
missing --parent parameter. No revision is made iin both cases - great.

Thanks a lot.

T.M.
Bert Huijben
2017-02-15 13:50:13 UTC
Permalink
Post by Andrew Reedick
-----Original Message-----
Sent: woensdag 15 februari 2017 08:41
Subject: Re: how to detect read-only branch from client?
Not a complete solution, but it's a start. Craft a "svn mkdir" that
includes the url to test and a url that will always fail
That's it. The key is to create a nested directory in a branch, this
means a directory which has a non-existing parent, and doing that
Test/ro is a readonly branch
Test/rw is a normal (read/write) branch
$ svn mkdir -m"xx" https://repository/svn/Binaries/Test/ro/a/b"
svn: E175013: Access to '/svn/Binaries/!svn/txr/50-1u/Test/ro/a/b' forbidden
$ svn mkdir -m"xx" https://repository/svn/Binaries/Test/rw/a/b"
svn: E160013: Try 'svn mkdir --parents' instead?
svn: E160013: File not found: transaction '50-1v', path '/Test/rw/a/b'
This gives two distiguishable messages: in the first case it fails
because of the readonly property, in the second case because of the
missing --parent parameter. No revision is made iin both cases - great.
A better way would be to perform the operation, but *not* specify a log
message and configure no editor either. In that case the operation will fail
client side after these checks via the missing log message.


But then there is always the option that the read-only-ness is applied via a
hook script... And in this case this trickery just fails.

Bert

Loading...