You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Jon Bendtsen <Jo...@laerdal.dk> on 2005/09/09 12:10:58 UTC

[hook-script] new pre-commit script to add bugzilla urls to log messages

Hi whoever is interested.

I have made a pre-commit hook script that adds bugzilla urls to log  
messages.
It is a bash shell script, and it uses cut, sed, grep, echo, ...
It works on my debian stable using subversion 1.2.0-1 from testing?

This script CHANGES the props file in the transaction directory.
It has 2 paramters, first the repository, next the transaction.

 From those parameters it finds the right props file, and starts to  
parse it.
First it checks if the svn:log is the last of the svn: properties, if  
not, it aborts.

2. it checks if the extracted logmessage size and the log message  
size in the
props file matches. If not, it aborts, because it extracted the log  
message wrong.

3. it parses the logmessage finds text and numbers starting with
"bug " and any number comming after the word bug. Any non
whitespace, commas, points, #, +, and alike aborts the search
for more numbers. Any new "bug " restarts the search for numbers.

One may specify more than one bug number seperated by space , . + #

The bugnumber is appended to the bugurl and added to the logmessage.

4. finaly the new logmessage size is calculated and put into the  
props file.

 From here the commit proceeds as usual.


The bugurl is specified in the top of the script



JonB

Re: [hook-script] new pre-commit script to add bugzilla urls to log messages

Posted by Philip Martin <ph...@codematters.co.uk>.
Jon Bendtsen <Jo...@laerdal.dk> writes:

> Den 9. sep 2005 kl. 17:24 skrev Philip Martin:
>
>> #!/usr/bin/python
>> import sys
>> sys.path.append('/usr/local/subversion/lib/svn-python')
>> from svn import repos, fs
>> repos_handle = repos.open(sys.argv[1])
>> fs_handle = repos.fs(repos_handle)
>> txn_handle = fs.open_txn(fs_handle, sys.argv[2])
>> log_msg = fs.txn_proplist(txn_handle)['svn:log']
>> log_msg = log_msg + ' modified' # do the fancy bug URL stuff here
>> fs.change_txn_prop(txn_handle, 'svn:log', log_msg)
>
> Why are these language bindings not documented on the web?

I don't know, perhaps nobody has created any such documentation, I
don't really use the bindings myself.  The bindings are still being
developed and tend to lag behind the C API, you may need to use
Subversion 1.3 for that script to work.

-- 
Philip Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: [hook-script] new pre-commit script to add bugzilla urls to log messages

Posted by Philip Martin <ph...@codematters.co.uk>.
Jon Bendtsen <Jo...@laerdal.dk> writes:

> Den 9. sep 2005 kl. 17:24 skrev Philip Martin:
>
>> #!/usr/bin/python
>> import sys
>> sys.path.append('/usr/local/subversion/lib/svn-python')
>> from svn import repos, fs
>> repos_handle = repos.open(sys.argv[1])
>> fs_handle = repos.fs(repos_handle)
>> txn_handle = fs.open_txn(fs_handle, sys.argv[2])
>> log_msg = fs.txn_proplist(txn_handle)['svn:log']
>> log_msg = log_msg + ' modified' # do the fancy bug URL stuff here
>> fs.change_txn_prop(txn_handle, 'svn:log', log_msg)
>
> Why are these language bindings not documented on the web?

I don't know, perhaps nobody has created any such documentation, I
don't really use the bindings myself.  The bindings are still being
developed and tend to lag behind the C API, you may need to use
Subversion 1.3 for that script to work.

-- 
Philip Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [hook-script] new pre-commit script to add bugzilla urls to log messages

Posted by Jon Bendtsen <Jo...@laerdal.dk>.
Den 9. sep 2005 kl. 17:24 skrev Philip Martin:

> Jon Bendtsen <Jo...@laerdal.dk> writes:
>
>
>> I have made a pre-commit hook script that adds bugzilla urls to log
>> messages.
>> It is a bash shell script, and it uses cut, sed, grep, echo, ...
>> It works on my debian stable using subversion 1.2.0-1 from testing?
>>
>> This script CHANGES the props file in the transaction directory.
>>
>
> Eeek!  Modifying the database files directly is not recommended.  It
> would be better to use the language bindings:

Yeah i know, but i couldnt find any other way to change it before  
committing.


> #!/usr/bin/python
> import sys
> sys.path.append('/usr/local/subversion/lib/svn-python')
> from svn import repos, fs
> repos_handle = repos.open(sys.argv[1])
> fs_handle = repos.fs(repos_handle)
> txn_handle = fs.open_txn(fs_handle, sys.argv[2])
> log_msg = fs.txn_proplist(txn_handle)['svn:log']
> log_msg = log_msg + ' modified' # do the fancy bug URL stuff here
> fs.change_txn_prop(txn_handle, 'svn:log', log_msg)

Why are these language bindings not documented on the web?
At least not in anyplace i have looked. Naturally i look from
     http://subversion.tigris.org/
and i've been looking under
     Documents & files
     the subversion book
     development.

I just cant find it. Maybe if the language bindings was more easily  
found i would not
have used the wrong way to do things. And it's not like it is the  
first time i've been
looking for the language bindings. Back when i made a patch for  
mailer.py i looked
after them as well, but the documentation is gone.



JonB

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [hook-script] new pre-commit script to add bugzilla urls to log messages

Posted by Jon Bendtsen <Jo...@laerdal.dk>.
Den 9. sep 2005 kl. 17:24 skrev Philip Martin:

> Jon Bendtsen <Jo...@laerdal.dk> writes:
>
>
>> I have made a pre-commit hook script that adds bugzilla urls to log
>> messages.
>> It is a bash shell script, and it uses cut, sed, grep, echo, ...
>> It works on my debian stable using subversion 1.2.0-1 from testing?
>>
>> This script CHANGES the props file in the transaction directory.
>>
>
> Eeek!  Modifying the database files directly is not recommended.  It
> would be better to use the language bindings:

Yeah i know, but i couldnt find any other way to change it before  
committing.


> #!/usr/bin/python
> import sys
> sys.path.append('/usr/local/subversion/lib/svn-python')
> from svn import repos, fs
> repos_handle = repos.open(sys.argv[1])
> fs_handle = repos.fs(repos_handle)
> txn_handle = fs.open_txn(fs_handle, sys.argv[2])
> log_msg = fs.txn_proplist(txn_handle)['svn:log']
> log_msg = log_msg + ' modified' # do the fancy bug URL stuff here
> fs.change_txn_prop(txn_handle, 'svn:log', log_msg)

Why are these language bindings not documented on the web?
At least not in anyplace i have looked. Naturally i look from
     http://subversion.tigris.org/
and i've been looking under
     Documents & files
     the subversion book
     development.

I just cant find it. Maybe if the language bindings was more easily  
found i would not
have used the wrong way to do things. And it's not like it is the  
first time i've been
looking for the language bindings. Back when i made a patch for  
mailer.py i looked
after them as well, but the documentation is gone.



JonB

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Adding new files

Posted by S I <xi...@hotmail.com>.
Ok, great and thank you.

----Original Message Follows----
From: Ryan Schmidt <su...@ryandesign.com>
To: S I <xi...@hotmail.com>
CC: users@subversion.tigris.org
Subject: Re: Adding new files
Date: Fri, 9 Sep 2005 19:06:10 +0200
MIME-Version: 1.0 (Apple Message framework v734)
Received: from server20.hostpoint.ch ([217.26.52.30]) by mc2-f34.hotmail.com 
with Microsoft SMTPSVC(6.0.3790.211); Fri, 9 Sep 2005 10:06:14 -0700
Received: from [195.145.7.218] (helo=[172.25.1.2])by server20.hostpoint.ch 
with esmtpa (Exim 4.43 (FreeBSD))id 1EDmKJ-00080M-BD; Fri, 09 Sep 2005 
19:06:11 +0200
X-Message-Info: JGTYoYF78jGw3GkHJPVg53eVvlKABun1Z/xhCV8rfQw=
References: <BA...@phx.gbl>
X-Mailer: Apple Mail (2.734)
X-AntiAbuse: This header was added to track abuse, please include it with 
any abuse report
X-AntiAbuse: Primary Hostname - server20.hostpoint.ch
X-AntiAbuse: Original Domain - hotmail.com
X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [26 6]
X-AntiAbuse: Sender Address Domain - ryandesign.com
Return-Path: subversion-2005@ryandesign.com
X-OriginalArrivalTime: 09 Sep 2005 17:06:14.0464 (UTC) 
FILETIME=[C90F5400:01C5B560]

On Sep 9, 2005, at 18:30, S I wrote:

>I just created new dir and moved bunch of files into it via Win  Explorer.  
>In a DOS prompt I did the following:
>
>1. svn mkdir lib
>C:\trunk\build>svn mkdir lib
>A         lib
>
>2. svn add lib
>C:\trunk\build>svn commit -m "Creating files" lib
>Adding         lib
>
>Committed revision 11.
>
>3. cd lib
>
>4. svn log filename
>svn: 'mail.jar' is not under version control
>
>What am I doing wrong? I thought do ing svn mkdir and svn add at a  
>directory level automatically checked in the files under it.

"svn mkdir lib" is a shortcut for "mkdir lib && svn add lib". So when  you 
then performed an "svn add lib" after adding files to the lib  directory, it 
did nothing, because lib had already been added by the  "svn mkdir" command.

You could either have done it like this:

$ svn mkdir lib
# now add stuff to it via windows explorer
$ svn add lib/*
$ svn ci lib

Or like this:

$ mkdir lib
# now add stuff to it via windows explorer
$ svn add lib
$ svn ci lib



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Adding new files

Posted by Ryan Schmidt <su...@ryandesign.com>.
On Sep 9, 2005, at 18:30, S I wrote:

> I just created new dir and moved bunch of files into it via Win  
> Explorer.  In a DOS prompt I did the following:
>
> 1. svn mkdir lib
> C:\trunk\build>svn mkdir lib
> A         lib
>
> 2. svn add lib
> C:\trunk\build>svn commit -m "Creating files" lib
> Adding         lib
>
> Committed revision 11.
>
> 3. cd lib
>
> 4. svn log filename
> svn: 'mail.jar' is not under version control
>
> What am I doing wrong? I thought do ing svn mkdir and svn add at a  
> directory level automatically checked in the files under it.

"svn mkdir lib" is a shortcut for "mkdir lib && svn add lib". So when  
you then performed an "svn add lib" after adding files to the lib  
directory, it did nothing, because lib had already been added by the  
"svn mkdir" command.

You could either have done it like this:

$ svn mkdir lib
# now add stuff to it via windows explorer
$ svn add lib/*
$ svn ci lib

Or like this:

$ mkdir lib
# now add stuff to it via windows explorer
$ svn add lib
$ svn ci lib



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Adding new files

Posted by S I <xi...@hotmail.com>.
Hi

I just created new dir and moved bunch of files into it via Win Explorer.  
In a DOS prompt I did the following:

1. svn mkdir lib
C:\trunk\build>svn mkdir lib
A         lib

2. svn add lib
C:\trunk\build>svn commit -m "Creating files" lib
Adding         lib

Committed revision 11.

3. cd lib

4. svn log filename
svn: 'mail.jar' is not under version control

What am I doing wrong? I thought do ing svn mkdir and svn add at a directory 
level automatically checked in the files under it.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: [hook-script] new pre-commit script to add bugzilla urls to log messages

Posted by Philip Martin <ph...@codematters.co.uk>.
Jon Bendtsen <Jo...@laerdal.dk> writes:

> I have made a pre-commit hook script that adds bugzilla urls to log
> messages.
> It is a bash shell script, and it uses cut, sed, grep, echo, ...
> It works on my debian stable using subversion 1.2.0-1 from testing?
>
> This script CHANGES the props file in the transaction directory.

Eeek!  Modifying the database files directly is not recommended.  It
would be better to use the language bindings:

#!/usr/bin/python
import sys
sys.path.append('/usr/local/subversion/lib/svn-python')
from svn import repos, fs
repos_handle = repos.open(sys.argv[1])
fs_handle = repos.fs(repos_handle)
txn_handle = fs.open_txn(fs_handle, sys.argv[2])
log_msg = fs.txn_proplist(txn_handle)['svn:log']
log_msg = log_msg + ' modified' # do the fancy bug URL stuff here
fs.change_txn_prop(txn_handle, 'svn:log', log_msg)

-- 
Philip Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: [hook-script] new pre-commit script to add bugzilla urls to log messages

Posted by Philip Martin <ph...@codematters.co.uk>.
Jon Bendtsen <Jo...@laerdal.dk> writes:

> I have made a pre-commit hook script that adds bugzilla urls to log
> messages.
> It is a bash shell script, and it uses cut, sed, grep, echo, ...
> It works on my debian stable using subversion 1.2.0-1 from testing?
>
> This script CHANGES the props file in the transaction directory.

Eeek!  Modifying the database files directly is not recommended.  It
would be better to use the language bindings:

#!/usr/bin/python
import sys
sys.path.append('/usr/local/subversion/lib/svn-python')
from svn import repos, fs
repos_handle = repos.open(sys.argv[1])
fs_handle = repos.fs(repos_handle)
txn_handle = fs.open_txn(fs_handle, sys.argv[2])
log_msg = fs.txn_proplist(txn_handle)['svn:log']
log_msg = log_msg + ' modified' # do the fancy bug URL stuff here
fs.change_txn_prop(txn_handle, 'svn:log', log_msg)

-- 
Philip Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org