You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Chia-liang Kao <cl...@clkao.org> on 2005/02/26 04:19:11 UTC
hooks and env
Hi,
So I'm trying to implement a pre-commit hook that is going to be installed by
svk for the repositories it touches, to prevent accidental commits into mirrored
paths by non-svk clients, which would lead to inconsistent states.
So I have to distinguish the program invoking the commit. An obvious way is to
set SVK environment variable from the svk library, and check so in the hook.
However the run_hook_cmd in libsvn_repos has:
err = svn_io_run_cmd (".", cmd, args, &exitcode, &exitwhy, FALSE,
stdin_handle, null_handle, write_errhandle, pool);
The FALSE indicates the hook is run under clean environment. So the $ENV{SVK}
thing won't work.
What can I do to implement what I want in the hook?
Cheers,
CLK
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: hooks and env
Posted by "C. Michael Pilato" <cm...@collab.net>.
Chia-liang Kao <cl...@clkao.org> writes:
> On Sat, Feb 26, 2005 at 12:39:48AM -0600, C. Michael Pilato wrote:
> > > What can I do to implement what I want in the hook?
> >
> > Does SVK not set any transaction properties that are distinguishable
> > from a well-behaved-yet-non-SVK client? If so, perhaps just teach
> > your hook to look for those transaction properties. If not, perhaps
> > teach SVN to set such a property, and teach to the pre-commit hook to
> > check for it, and then remove it.
>
> This brings up another missing API long in mind. Most of the commits
> svk or svn::mirror performs are with repos commit_editor eventually in
> the last layer. But there's no way to access the txn object, and thus
> no way to set revprop with txnprop until the committed callback.
Interesting. Perhaps svn_repos_get_commit_editor() should do the txn
creation (instead of delaying until editor->open_root() is called),
return to the caller the editor, edit_baton, *and* the txn associated
with the edit.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: hooks and env
Posted by Chia-liang Kao <cl...@clkao.org>.
On Sat, Feb 26, 2005 at 12:39:48AM -0600, C. Michael Pilato wrote:
> > What can I do to implement what I want in the hook?
>
> Does SVK not set any transaction properties that are distinguishable
> from a well-behaved-yet-non-SVK client? If so, perhaps just teach
> your hook to look for those transaction properties. If not, perhaps
> teach SVN to set such a property, and teach to the pre-commit hook to
> check for it, and then remove it.
This brings up another missing API long in mind. Most of the commits
svk or svn::mirror performs are with repos commit_editor eventually in
the last layer. But there's no way to access the txn object, and thus
no way to set revprop with txnprop until the committed callback.
Cheers
CLK
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: hooks and env
Posted by "C. Michael Pilato" <cm...@collab.net>.
Chia-liang Kao <cl...@clkao.org> writes:
> Hi,
>
> So I'm trying to implement a pre-commit hook that is going to be
> installed by svk for the repositories it touches, to prevent
> accidental commits into mirrored paths by non-svk clients, which
> would lead to inconsistent states.
>
> So I have to distinguish the program invoking the commit. An
> obvious way is to set SVK environment variable from the svk library,
> and check so in the hook.
>
> However the run_hook_cmd in libsvn_repos has:
>
> err = svn_io_run_cmd (".", cmd, args, &exitcode, &exitwhy, FALSE,
> stdin_handle, null_handle, write_errhandle, pool);
>
> The FALSE indicates the hook is run under clean environment. So the
> $ENV{SVK} thing won't work.
>
> What can I do to implement what I want in the hook?
Does SVK not set any transaction properties that are distinguishable
from a well-behaved-yet-non-SVK client? If so, perhaps just teach
your hook to look for those transaction properties. If not, perhaps
teach SVN to set such a property, and teach to the pre-commit hook to
check for it, and then remove it.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org