You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Lucas van Staden <lv...@softhome.net> on 2005/11/12 23:04:50 UTC
howto pass command-line option from svn client to repository....(new option --skip-post-commit)
Hi.
Firstly I will give an explanation on what I am trying to do, as I may be
going about the wrong way to achieve this. Currently the only solution I can
fathom is to create a new command line option for svn client(s).
If I am going about this in the wrong way, or there is some documentation I
can read to understand this, do please point me into the right direction. All
in all this has been fun.....
So here goes....
Been using subversion for a while now in a multi developer web development
environment.
After new functions were developed, our marketing team needs to check and
approve them before they go live, so to enable this we work each new function
as a branch off the main trunk, each accessable as a seperate url, thus
functiona becomes http://functiona.site.co.uk, function2 becomes
functionb.site.co.uk etc etc.
Once a functions has been approved we merge that back into the main trunk,
take a snapshot into tags and release the code to stage for a final check and
then live.
Up to now the process has been a bit manual, with us having to create each
apache virtual host entry for each function, dns entries to get it company
wide available etc.
Some functions go live before others, so we have to make sure we dont send a
function that is still not approved to trunk and live. (plan to make some
kind of dependancy checking here via the hook scripts, so a function can't go
live if a dependancy has not yet been sent live)
(breath, phew)
I have begun to automate this process using the hook scripts, so now when we
use our svn clients (linux) to create a branch folder, and commit this folder
to the repository, the hook scripts create the required apache folder (more
on this in next paragraph), creates the apache vhost entries (working) and
adds the required dns entry into bind (working), which then gets replicated
to the main windows domain dns servers (waiting for the network guys to get
back to me on this).
(and breathe again)
Sofar everything is working good, appart from the creation of the apache
folders (the most crucial bit - read on this is a development issue...;)..),
the process is as follows:
Post-commit hook script checks to see a folder with the name of the branch
exists, and if not creates it, and does an inplace checkout as described in
the faq to make it an active svn workdir to the branch in the repository.
It then copies all the source files (php/javascript/html templates) into this
folder, and does a svn add on these, followed by a commit (can you see the
issue yet?)
It then copies the images etc that is not required to be in the repository to
make the new folder a complete working website, and creates the required
apache vhost settings and dns setting. The developer then just does an svn
update on the branch folder on his pc, and all the files are ready for him to
work on :)
The issue is that when the post-commit script does the commit, the commit
itself triggers the post-commit script again. This can at times send the
process into an endless loop, and also slow the process down, creating more
new folders etc.
Now I thought of creating a new option called --skip-post-commit for the svn
client, which would then be included in the svn commit used by the
post-commit script. (I come from a delphi/pascal background, never actually
done any c....)
Sofar what I have done (simple stuff for you guys) was to add the new option
to the /clients/cmdline code (all fine and working, running svn with
--skip-post-commit detects the new option)
I adjusted the svn_repos_fs_commit_txn function to look like this :
svn_repos_fs_commit_txn (const char **conflict_p,
svn_repos_t *repos,
svn_revnum_t *new_rev,
svn_fs_txn_t *txn,
apr_pool_t *pool,
svn_boolean_t *skippost)
so now in fs-wrap.c i can skip the post-commit call by checking if skippost is
true or false.
So, the call to this in libsvn_repos now looks like this:
err = svn_repos_fs_commit_txn (&conflict, eb->repos,
&new_revision, eb->txn, pool,TRUE);
This seems to work, as I can place a FALSE in the call, recompile and the
post-commit is skipped.
What I cannot figure out is how now to know at this point if the
--skip-post-commit option was included in the svn client call, and thus send
the appropriate true/false value in the call.
I am setting opt_state accordingly in main.c in the command line main.c, so
how do I referance back to that in fs-wrap.c (opt_state class does not exist
at this point)
Any help would be appreciated.
Lucas
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: howto pass command-line option from svn client to repository....(new option --skip-post-commit)
Posted by Lucas van Staden <lv...@softhome.net>.
Hi.
On Tuesday 15 November 2005 14:43, Max Bowsher wrote:
> Lucas van Staden wrote:
> [snipped: Using svn in web development environment.
> Many branches. Wants to automate Apache/DNS setup that goes along
> with creating a new branch.]
>
> > I have begun to automate this process using the hook scripts, so now when
> > we use our svn clients (linux) to create a branch folder, and commit this
> > folder to the repository, the hook scripts create the required apache
> > folder (more on this in next paragraph), creates the apache vhost entries
> > (working) and adds the required dns entry into bind (working), which then
> > gets replicated to the main windows domain dns servers (waiting for the
> > network guys to get back to me on this).
> >
> > (and breathe again)
> >
> > Sofar everything is working good, appart from the creation of the apache
> > folders (the most crucial bit - read on this is a development
> > issue...;)..), the process is as follows:
> >
> > Post-commit hook script checks to see a folder with the name of the
> > branch exists, and if not creates it, and does an inplace checkout as
> > described in the faq to make it an active svn workdir to the branch in
> > the repository. It then copies all the source files (php/javascript/html
> > templates) into this folder, and does a svn add on these, followed by a
> > commit (can you see the issue yet?)
>
> OK, now this is the first bit which puzzles me. The client is creating
> an empty directory to contain the branch, and then the server fills it
> in? Why do things this way, rather than have the client do "svn copy
> TRUNK-URL BRANCH-URL", and have the post-commit just do a checkout of
> the new branch?
>
> ...
:) Yes, i have been overthinking things (sometimes I go a bit crazy, ok....)
>
> > The issue is that when the post-commit script does the commit, the commit
> > itself triggers the post-commit script again. This can at times send the
> > process into an endless loop, and also slow the process down, creating
> > more new folders etc.
> >
> > Now I thought of creating a new option called --skip-post-commit for the
> > svn client, which would then be included in the svn commit used by the
> > post-commit script.
>
> Whoa! Serious over-engineering.
>
> If the post-commit is only supposed to do anything when it sees a branch
> directory being created, just make the post-commit check whether this is
> the case, and exit if not, before doing anything else.
>
> Max.
Once again, I been a bit crazy...., I have already dropped this idea.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: howto pass command-line option from svn client to repository....(new
option --skip-post-commit)
Posted by Max Bowsher <ma...@ukf.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Lucas van Staden wrote:
[snipped: Using svn in web development environment.
Many branches. Wants to automate Apache/DNS setup that goes along
with creating a new branch.]
> I have begun to automate this process using the hook scripts, so now when we
> use our svn clients (linux) to create a branch folder, and commit this folder
> to the repository, the hook scripts create the required apache folder (more
> on this in next paragraph), creates the apache vhost entries (working) and
> adds the required dns entry into bind (working), which then gets replicated
> to the main windows domain dns servers (waiting for the network guys to get
> back to me on this).
>
> (and breathe again)
>
> Sofar everything is working good, appart from the creation of the apache
> folders (the most crucial bit - read on this is a development issue...;)..),
> the process is as follows:
>
> Post-commit hook script checks to see a folder with the name of the branch
> exists, and if not creates it, and does an inplace checkout as described in
> the faq to make it an active svn workdir to the branch in the repository.
> It then copies all the source files (php/javascript/html templates) into this
> folder, and does a svn add on these, followed by a commit (can you see the
> issue yet?)
OK, now this is the first bit which puzzles me. The client is creating
an empty directory to contain the branch, and then the server fills it
in? Why do things this way, rather than have the client do "svn copy
TRUNK-URL BRANCH-URL", and have the post-commit just do a checkout of
the new branch?
...
> The issue is that when the post-commit script does the commit, the commit
> itself triggers the post-commit script again. This can at times send the
> process into an endless loop, and also slow the process down, creating more
> new folders etc.
>
> Now I thought of creating a new option called --skip-post-commit for the svn
> client, which would then be included in the svn commit used by the
> post-commit script.
Whoa! Serious over-engineering.
If the post-commit is only supposed to do anything when it sees a branch
directory being created, just make the post-commit check whether this is
the case, and exit if not, before doing anything else.
Max.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
iD8DBQFDefQLfFNSmcDyxYARAlIxAKC6kgBPyFRiTHNH5nsWTkiZv1dqbACgkogP
vT2phohpD+OpBJAvG8ysdEo=
=c2yI
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
When can a hook make a change to the repository?
Posted by kf...@collab.net.
[I've left this in the thread, but changed the subject line and CC'd
users@subversion, since I think it might be of interest there.
Probably this should become a FAQ item, if it's not already.]
Ximon Eighteen <xi...@int.greenpeace.org> writes:
> > Post-commit hook script checks to see a folder with the name of the
> >branch exists, and if not creates it, and does an inplace checkout as
> >described in the faq to make it an active svn workdir to the branch
> >in the repository. It then copies all the source files
> >(php/javascript/html templates) into this folder, and does a svn add
> >on these, followed by a commit (can you see the issue yet?)
>
> It's my understanding that hooks are not allowed to change the
> repository.
That's not quite right; the actual guidelines are a bit more complex.
In the pre-commit hook, you should not change versionable items in the
txn being committed, because there would be no way for the working
copy to find out about your changes -- the working copy would think it
was up-to-date after the commit, when in fact it would not be.
(However, note that it's not necessarily bad for pre-commit to set or
change unversioned revprops on the txn, as long as it is careful with
things like svn:date.)
In post-commit, it's fine to make further changes to the repository,
but you should make sure you don't accidentally start a hook loop:
whatever change your post-commit hook makes, it should not be of the
sort that would cause post-commit to be invoked again in such a way
that it would want to make the same kind of change, thus resulting in
another invocation of post-commit... You get the idea :-).
-Karl
--
www.collab.net <> CollabNet | Distributed Development On Demand
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
When can a hook make a change to the repository?
Posted by kf...@collab.net.
[I've left this in the thread, but changed the subject line and CC'd
users@subversion, since I think it might be of interest there.
Probably this should become a FAQ item, if it's not already.]
Ximon Eighteen <xi...@int.greenpeace.org> writes:
> > Post-commit hook script checks to see a folder with the name of the
> >branch exists, and if not creates it, and does an inplace checkout as
> >described in the faq to make it an active svn workdir to the branch
> >in the repository. It then copies all the source files
> >(php/javascript/html templates) into this folder, and does a svn add
> >on these, followed by a commit (can you see the issue yet?)
>
> It's my understanding that hooks are not allowed to change the
> repository.
That's not quite right; the actual guidelines are a bit more complex.
In the pre-commit hook, you should not change versionable items in the
txn being committed, because there would be no way for the working
copy to find out about your changes -- the working copy would think it
was up-to-date after the commit, when in fact it would not be.
(However, note that it's not necessarily bad for pre-commit to set or
change unversioned revprops on the txn, as long as it is careful with
things like svn:date.)
In post-commit, it's fine to make further changes to the repository,
but you should make sure you don't accidentally start a hook loop:
whatever change your post-commit hook makes, it should not be of the
sort that would cause post-commit to be invoked again in such a way
that it would want to make the same kind of change, thus resulting in
another invocation of post-commit... You get the idea :-).
-Karl
--
www.collab.net <> CollabNet | Distributed Development On Demand
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: howto pass command-line option from svn client to repository....(new
option --skip-post-commit)
Posted by Ximon Eighteen <xi...@int.greenpeace.org>.
> Post-commit hook script checks to see a folder with the name of the branch
> exists, and if not creates it, and does an inplace checkout as described in
> the faq to make it an active svn workdir to the branch in the repository.
> It then copies all the source files (php/javascript/html templates) into this
> folder, and does a svn add on these, followed by a commit (can you see the
> issue yet?)
It's my understanding that hooks are not allowed to change the repository.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: howto pass command-line option from svn client to repository....(new option --skip-post-commit)
Posted by Molle Bestefich <mo...@gmail.com>.
Lucas van Staden wrote:
> Post-commit hook script checks to see a folder with the name of the branch
> exists, and if not creates it, and does an inplace checkout as described in
> the faq to make it an active svn workdir to the branch in the repository.
> It then copies all the source files (php/javascript/html templates) into this
> folder, and does a svn add on these, followed by a commit (can you see the
> issue yet?)
I can see another issue. Seems a waste of space in the repository.
Why not use svn:externals and modify the svn:externals property to be
fixated (-r xxx syntax) whenever a copy to a branch is made?
> It then copies the images etc that is not required to be in the repository to
> make the new folder a complete working website, and creates the required
> apache vhost settings and dns setting. The developer then just does an svn
> update on the branch folder on his pc, and all the files are ready for him to
> work on :)
Except for the images, I guess.
> The issue is that when the post-commit script does the commit, the commit
> itself triggers the post-commit script again. This can at times send the
> process into an endless loop, and also slow the process down, creating more
> new folders etc.
>
> Now I thought of creating a new option called --skip-post-commit for the svn
> client, which would then be included in the svn commit used by the
> post-commit script. (I come from a delphi/pascal background, never actually
> done any c....)
There's the option of setting a property on the top folder you're
working on. Before the p-c script does it's commit, it could set this
property on the WC, to indicate it's running. The other p-c script
should (before it starts doing anything, obviously) check for the
existence of this property in the transaction by using svnlook propget
and just 'exit 0' if it's there.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org