Post-Commit Hook Protocol (http, svn, file) in Tortoise SVN

554 views
Skip to first unread message

Michael R

unread,
Feb 17, 2010, 6:46:15 PM2/17/10
to d...@tortoisesvn.tigris.org
I'm building a post-commit client hook for Tortoise SVN. This hook
communicates with another application that keeps a separate record of
the commits that occur. When the hook is executed, I want to pass the
list of files that were committed to the other application. My
problem is that this list of files doesn't include the full protocol
to the file--just the local system path. How can I get TortoiseSVN to
give me the full protocol path (http:// or file:/// or svn://)?

For example:
-Now I am being handed a list of files through the PATH file
parameter, i.e.:
C:\local repository\project1\thisfile.txt
C:\local repository\project1\anotherfile.txt

-Because this hook could be used by people committing files either
through some Apache web server or through a svnserve service, I'd like
to be handed the full path, like this:

http://someserver/project1/thisfile.txt
http://someserver/project1/anotherfile.txt

or

svn://someserver/project1/thisfile.txt
svn://someserver/project1/anotherfile.txt

What's the best way to do this?

Thanks,

Michael R

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=757&dsMessageId=2448590

To unsubscribe from this discussion, e-mail: [dev-uns...@tortoisesvn.tigris.org].

Jean-Marc van Leerdam

unread,
Feb 18, 2010, 1:33:25 AM2/18/10
to d...@tortoisesvn.tigris.org
Hi,

On 18 February 2010 00:46, Michael R <arpha...@gmail.com> wrote:
> I'm building a post-commit client hook for Tortoise SVN.  This hook
> communicates with another application that keeps a separate record of
> the commits that occur.  When the hook is executed, I want to pass the
> list of files that were committed to the other application.  My
> problem is that this list of files doesn't include the full protocol
> to the file--just the local system path.  How can I get TortoiseSVN to
> give me the full protocol path (http:// or file:/// or svn://)?
>
> For example:
> -Now I am being handed a list of files through the PATH file
> parameter, i.e.:
> C:\local repository\project1\thisfile.txt
> C:\local repository\project1\anotherfile.txt
>
> -Because this hook could be used by people committing files either
> through some Apache web server or through a svnserve service, I'd like
> to be handed the full path, like this:
>
> http://someserver/project1/thisfile.txt
> http://someserver/project1/anotherfile.txt
>
> or
>
> svn://someserver/project1/thisfile.txt
> svn://someserver/project1/anotherfile.txt
>
> What's the best way to do this?
>

What is the reason you are not using server side hooks for this? The
client side will only catch your local commits done through TSVN; any
other commit -- through different SVN clients or from other machines
will not be caught.

And why is it relevant to see/know the protocol that was used for the commit?

The server side will know the repository location of the affected
files, not the local working copy paths nor the protocol that was used
(I think).

--
Regards,

Jean-Marc
--
. ___
. @@ // \\ "De Chelonian Mobile"
. (_,\/ \_/ \ TortoiseSVN
. \ \_/_\_/> The coolest Interface to (Sub)Version Control
. /_/ \_\ http://tortoisesvn.net

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=757&dsMessageId=2448661

Michael R

unread,
Feb 18, 2010, 2:38:21 PM2/18/10
to d...@tortoisesvn.tigris.org
> And why is it relevant to see/know the protocol that was used for the commit?

It's relevant because my application stores the commits paths and
allows the user to click "get history" without having to go to
subversion or TSVN. To do a "get history" on that file from the app,
I need to know what the protocol is and the full path (C:/workspace/
file1.txt is only helpful to the user who performed the commit....
svn://someserver/workspace/file1.txt can be viewed by anyone).

You said I can't get this information from a server-side hook. Can I
get it from a client-side hook?

Michael R


On Feb 17, 11:33 pm, Jean-Marc van Leerdam <j.m.van.leer...@gmail.com>
wrote:
> Hi,

> ------------------------------------------------------http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=757&dsMessa...
>
> To unsubscribe from this discussion, e-mail: [dev-unsubscr...@tortoisesvn.tigris.org].

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=757&dsMessageId=2448899

Oto BREZINA

unread,
Feb 18, 2010, 3:16:14 PM2/18/10
to d...@tortoisesvn.tigris.org, Michael R
Dear Michael,

If you know local repository path "svn info" command would give you info
about svn connection used.

Still don't understand why you need full path to svn repository. Every
user can theoricaly use dufferent way to connect to same repository, so
I would expect that you need identify repository (by UUID for example),
and path in it - relative to repository root. Anythin else may add
confusion.

Oto

But i

> ________ Information from NOD32 ________
> This message was checked by NOD32 Antivirus System for Linux Mail Servers.
> part000.txt - is OK
> http://www.eset.com
>

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=757&dsMessageId=2448905

Stefan Küng

unread,
Feb 18, 2010, 3:22:16 PM2/18/10
to d...@tortoisesvn.tigris.org
On 18.02.2010 20:38, Michael R wrote:
>> And why is it relevant to see/know the protocol that was used for the commit?
>
> It's relevant because my application stores the commits paths and
> allows the user to click "get history" without having to go to
> subversion or TSVN. To do a "get history" on that file from the app,
> I need to know what the protocol is and the full path (C:/workspace/
> file1.txt is only helpful to the user who performed the commit....
> svn://someserver/workspace/file1.txt can be viewed by anyone).
>
> You said I can't get this information from a server-side hook. Can I
> get it from a client-side hook?

You don't need that information, because you already know it.
You'll get the paths relative to the repository root. So just Prepend
those paths with the url of the repository root and you have your full path.
Sure, you will need a different script for every repository, but that
shouldn't be a problem.

Stefan

--
___
oo // \\ "De Chelonian Mobile"
(_,\/ \_/ \ TortoiseSVN


\ \_/_\_/> The coolest Interface to (Sub)Version Control

/_/ \_\ http://tortoisesvn.net

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=757&dsMessageId=2448908

Michael R

unread,
Feb 19, 2010, 12:31:35 PM2/19/10
to d...@tortoisesvn.tigris.org
I'll explain my whole situation to make this more clear.

There is a defect-tracking application that I am working with. This
application has functionality that can link to Subversion:
-A user can enter a connection to Subversion (file:///, svn://, http://,
etc.) and credentials to the Subversion repository
-A user can then select a defect and click "Add Link"
...a window then opens in the defect application showing the
subversion repository, and the user can select one or more files in
the repository and click "OK"
...clicking "OK" then records some simple information about the
selected Subversion file in the repository
...the users can then scan through defects and click on a defect
and see which defects have been committed and against which subversion
files
-The information which is included is the "path" to the subversion
file, it can be in a (file:///, svn://, or http:// format) and the
revision number
...this is important because the defect tracking application has
some simple functionality such as "Get History" on the subversion
links
...(and yes, if the users enter things with file:/// then other
users won't be able to Get History on those items, but they can set up
Subversion however they wish)

What lies above is set functionality that I cannot change. What I am
interested in doing is adding to the functionality above.

I want to add support to this for Tortoise SVN and allow commits made
from Tortoise SVN to communicate back to the defect-tracking system
and create these simple entries. What I have created now is an
interface that talks to Tortoise SVN (that allows users to select
defects through the Tortoise SVN commit screen) and a post-commit hook
that relays the commited files and revisions over to the defect
tracking system. I've also written a setup package that nicely
installs all of this on 32 and 64 bit machines.

Which leads back to my original question...it all works fine at this
moment except for one problem: the files that are given to the hook
by Tortoise after the commit are in a "C:\project\file.txt" format
rather than the "http://server/file.txt" or "svn://server/file.txt"
format that the defect system requires.

One suggestions made above seemed to help for a bit (the bit about
running the "svn.eve info" command on each item through the hook).
This would work great for me except that I cannot rely on users having
the SVN client installed on their machine...a machine might only have
the Tortoise SVN client installed...I poked around looking at the
Tortoise SVN client and it looks like the Tortoise client does not
have an "info" command that matches the SVN one.

What is my best course of action to allow my hook to hand off the list
of committed files (post-commit) to the defect tracking application in
a http://, svn://, or file:/// format?

Thank you in advance.

> ------------------------------------------------------http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=757&dsMessa...
>
> To unsubscribe from this discussion, e-mail: [dev-unsubscr...@tortoisesvn.tigris.org].

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=757&dsMessageId=2449150

Stefan Küng

unread,
Feb 19, 2010, 4:06:19 PM2/19/10
to d...@tortoisesvn.tigris.org

You should implement an issue tracker plugin:
http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-ibugtraqprovider.html

Here are some plugins that already work, some of them open source so you
can check how they did it:
http://tortoisesvn.net/issuetrackerplugins

Stefan

--
___
oo // \\ "De Chelonian Mobile"
(_,\/ \_/ \ TortoiseSVN
\ \_/_\_/> The coolest Interface to (Sub)Version Control
/_/ \_\ http://tortoisesvn.net

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=757&dsMessageId=2449405

Michael R

unread,
Feb 19, 2010, 4:24:08 PM2/19/10
to d...@tortoisesvn.tigris.org
I *did* implement an issue tracker plugin...with an interface that
talks to Subversion, as I mentioned above. The user, in my example
above, uses the issue tracker plugin that I wrote, and their commit
executes the post-commit script I am talking about. My original
question is still not being answered.

In a post-commit hook, when I am handed a list of local committed
files from Tortoise (the first parameter in a post-commit hook), how
can I convert them into their proper protocol (http://, svn:// or file:///)
format and send them to my issue tracker? My issue tracker needs the
files with their respective protocol, not the local path to the
particular machine where the commit occurred.

> You should implement an issue tracker plugin:http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-ibugtraqprovi...


>
> Here are some plugins that already work, some of them open source so you
> can check how they did it:http://tortoisesvn.net/issuetrackerplugins
>
> Stefan
>
> --
>         ___
>    oo  // \\      "De Chelonian Mobile"
>   (_,\/ \_/ \     TortoiseSVN
>     \ \_/_\_/>    The coolest Interface to (Sub)Version Control
>     /_/   \_\    http://tortoisesvn.net
>

> ------------------------------------------------------http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=757&dsMessa...
>
> To unsubscribe from this discussion, e-mail: [dev-unsubscr...@tortoisesvn.tigris.org].

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=757&dsMessageId=2449408

Stefan Küng

unread,
Feb 19, 2010, 4:39:02 PM2/19/10
to d...@tortoisesvn.tigris.org
On 19.02.2010 22:24, Michael R wrote:
> I *did* implement an issue tracker plugin...with an interface that
> talks to Subversion, as I mentioned above. The user, in my example
> above, uses the issue tracker plugin that I wrote, and their commit
> executes the post-commit script I am talking about. My original
> question is still not being answered.
>
> In a post-commit hook, when I am handed a list of local committed
> files from Tortoise (the first parameter in a post-commit hook), how
> can I convert them into their proper protocol (http://, svn:// or file:///)
> format and send them to my issue tracker? My issue tracker needs the
> files with their respective protocol, not the local path to the
> particular machine where the commit occurred.

You have the commonUrl parameter in the plugin method, and you have the
commonRoot parameter. You can use those two and do a little string
manipulation to find the paths relative to the commonRoot, then prepend
the commonUrl to those relative paths and you got your urls.

Stefan

--
___
oo // \\ "De Chelonian Mobile"
(_,\/ \_/ \ TortoiseSVN
\ \_/_\_/> The coolest Interface to (Sub)Version Control
/_/ \_\ http://tortoisesvn.net

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=757&dsMessageId=2449410

Michael R

unread,
Feb 24, 2010, 10:35:21 AM2/24/10
to d...@tortoisesvn.tigris.org
OK this worked for me.

Thank you.

> ------------------------------------------------------http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=757&dsMessa...
>
> To unsubscribe from this discussion, e-mail: [dev-unsubscr...@tortoisesvn.tigris.org].

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=757&dsMessageId=2451589

Reply all
Reply to author
Forward
0 new messages