You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Jake Stone <ja...@gmail.com> on 2009/08/16 03:36:40 UTC

Hook Files Question

Hello!

I am running Subversion via Apache on Windows, and am writing a few 
batch script hooks, to do simple things like enforce a non-empty log 
message. To do some of these tasks, I create (and overwrite) small text 
files in the hooks directory, such as "email.txt" or similar.

I'm wondering about what might happen if while Person A is making Commit 
A, another Person B will try to start Commit B. Since Subversion is 
atomic, I do not have to worry about any commit B starting before commit 
A is done, correct? In other words, these batch file hooks cannot step 
on each other using common file names, because each commit finishes 
before the next begins, correct?

Thanks for the help!
Jake Stone

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2383973

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

Re: Hook Files Question

Posted by Jake Stone <ja...@gmail.com>.
Andrey: That is correct - I do things like compose & send an email 
message in my post-commit script, for example. My hooks are very simple 
(so far) and don't require anything outside batch files, so I will use 
the %TXT% method David mentioned. Thanks to all!
Jake Stone

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2384007

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

Re: Hook Files Question

Posted by Andrey Repin <an...@freemail.ru>.
Greetings, Jake Stone!

> I'm wondering about what might happen if while Person A is making Commit
> A, another Person B will try to start Commit B. Since Subversion is 
> atomic, I do not have to worry about any commit B starting before commit 
> A is done, correct? In other words, these batch file hooks cannot step 
> on each other using common file names, because each commit finishes 
> before the next begins, correct?

Basically, yes. If you need more in-depth explanation, you gonna ask more
specific questions :)

Fake edit:
If you mean that you're modifying your files at the time of hooks execution -
take care.
While Subversion operations is atomic, you COULD still run into situation
where 2 hooks being executed at the same time.


--
WBR,
 Andrey Repin (anrdaemon@freemail.ru) 16.08.2009, <9:30>

Sorry for my terrible english...

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2383989

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

Re: Hook Files Question

Posted by David Weintraub <qa...@gmail.com>.
On Mon, Aug 17, 2009 at 7:50 PM, Andrey Repin <an...@freemail.ru> wrote:

> Greetings, David Weintraub!
>
> > Truth be known, you're probably better off not using batch scripting.
> Batch
> > scripts are very limited language wise. There are few looping control
> > structures, etc. You have more control if you use something like Python
> or
> > Perl for your hook scripts.
>
> Not true...
> http://jpsoftware.com/tccledes.htm
> :)
> I've been using it's predecessor, 4NT, for ages as REPLACEMENT for cmd.exe.
>


Well, that isn't exactly the standard Batch programming language (via the
cmd.exe). It is a batch like cmd.exe replacement. From what I've seen in the
documentation, it looks like it can bring standard Batch scripting language
to the level of the BASH shell which means it is possible to actually write
Subversion hooks.

However, even with all the enhancements, it. still lacks the power of a true
programming language like Python or Perl.

I am a Perl programmer myself, but I would highly recommend anyone who
programs to learn Python which is becoming the standard "glue language" for
the Internet. All of the standard Subversion triggers are written in Python
now, and so is much of Google's infrastructure. Python is free and
multienvironment. It works in Windows, Linux, Unix, and Mac OS X. You can
also use the Eclipse Integrated Development Environment (also free and
multiplatformed) to do Python programming and debugging.

-- 
David Weintraub
qazwart@gmail.com

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2384883

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

Re: Hook Files Question

Posted by Andrey Repin <an...@freemail.ru>.
Greetings, David Weintraub!

> Truth be known, you're probably better off not using batch scripting. Batch
> scripts are very limited language wise. There are few looping control
> structures, etc. You have more control if you use something like Python or
> Perl for your hook scripts.

Not true...
http://jpsoftware.com/tccledes.htm
:)
I've been using it's predecessor, 4NT, for ages as REPLACEMENT for cmd.exe.


--
WBR,
 Andrey Repin (anrdaemon@freemail.ru) 18.08.2009, <3:43>

Sorry for my terrible english...

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2384576

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

Re: Hook Files Question

Posted by David Weintraub <qa...@gmail.com>.
Not too sure how you do this with Batch on Windows, but in Unix, the "$$" is
the process ID number of the current process.

We use this to help keep temporary file names unique on Unix systems. For
example:

echo "This is a test" > tempfile.$$.

If the Process ID was 2392, the temporary file name would be tempfile.2392.

Not too sure how this would be done in Windows batch. However, maybe you
could append the transaction number onto the name of the temporary files. I
believe this would be unique on each transaction if multiple transactions
are operating at once. Since the Transaction number is passed to your
script, it should be pretty easy to use:

set TXT=%2

echo "This is a test" > tempfile.%TXT%.txt

Or, something like that.

Truth be known, you're probably better off not using batch scripting. Batch
scripts are very limited language wise. There are few looping control
structures, etc. You have more control if you use something like Python or
Perl for your hook scripts.

The good thing is that hook scripts only run on the server, so you only need
to install Python or Perl on your server. In other revision control systems
like ClearCase, the hook scripts run on the client machine which means that
you have to make sure each client has your scripting language installed on
it.

On Sat, Aug 15, 2009 at 11:36 PM, Jake Stone <ja...@gmail.com>wrote:

> Hello!
>
> I am running Subversion via Apache on Windows, and am writing a few
> batch script hooks, to do simple things like enforce a non-empty log
> message. To do some of these tasks, I create (and overwrite) small text
> files in the hooks directory, such as "email.txt" or similar.
>
> I'm wondering about what might happen if while Person A is making Commit
> A, another Person B will try to start Commit B. Since Subversion is
> atomic, I do not have to worry about any commit B starting before commit
> A is done, correct? In other words, these batch file hooks cannot step
> on each other using common file names, because each commit finishes
> before the next begins, correct?
>
> Thanks for the help!
> Jake Stone
>
> ------------------------------------------------------
>
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2383973
>
> To unsubscribe from this discussion, e-mail: [
> users-unsubscribe@subversion.tigris.org].
>



-- 
David Weintraub
qazwart@gmail.com

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2383988

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].