[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Implementing custom context menu entries and extending tsvn: url scheme handler

From: Ben Summers <ben_at_fluffy.co.uk>
Date: 2007-09-06 18:03:56 CEST

Hello!

Thanks for all the hard work on TortoiseSVN. I'm using it as a front
end for SVN for a group of about 10 non-technical users who use it to
collaborate on a 12Gb collection of binary documents, mainly in MS
Office formats. It works really well with only a small amount of
training, which is pretty impressive for a front end to a source
control system aimed at software developers.

In relation to this non-standard use, I need to implement a couple of
features. I thought I would do this in a general enough manner to get
them accepted into the main source tree, and hope you'll help with
commenting on my plan and perhaps pointing me to appropriate bits of
the code.

These features are about making round trips to and from a web
application with minimal fuss:

1) Right click menu to open a URL: The user right clicks on the file
in Explorer, and chooses 'Open in X'. TortoiseSVN opens a URL into
which are substituted the repository URL, name, path etc.

2) Clicking on a link in the web site opens a Windows Explorer window
with the selected file highlighted. If it's not checked out on disc,
offer to check out the parent folder.

For the implementation, I'm thinking along the lines of

1) For the context menu, use something similar to "Integration with
Bugtracking Systems". A property would be read from the root of the
repository with name tsvn:contextmenu. This contains | separated
pairs of menu entry name and URL. The URL contains substitution
markers such as %URL%, %REPOSITORY%, %PATH%. For example, to add a
'View in Trac' menu entry, I would set the property to

   View in Trac|http://example.com/project/browser/%PATH%

I would see this menu entry below the SVN Update context menu entry,
and choosing it would open a web browser window for the file or
folder in Trac.

In this case I need to be able to set the properly on the root and
have it work everywhere below, even if the user has checked out a
subfolder or created new files. Because of the size of the
repositories, the users don't check out everything, and they
certainly won't be able to apply the properties to the new folders
they create. I think that ProjectProperties will recurse downwards to
find them in ReadPropsPathList(), but not below folders which are
checked out. If this is right, what's the best way of reading it from
the repository root?

To add the menu entries, I think I would need to add a small number
of entries to the list in TortoiseShell/ContextMenu.cpp, and then
when the menu is opened show or hide them and set the text label
appropriately. There may be some fun and games to transfer the
necessary information to and from the cache process.

An alternative implementation is to add some registry entries which
allow it to be set up globally for all repositories. This would do
fine for me, but is less general and so less useful to the project.

2) With the URL scheme for clicking a link in a web page, I'd extend
the tsvn: url scheme handler. It seems as reasonable as anything to
add a URL style parameter, as SVN itself doesn't use them. So ?
tsvnaction=locate appended to the URL would do the trick.

   tsvn:http://example.com/repo/path/to/file.txt?tsvnaction=locate

Implementing it is harder, because I don't think there's a store of
all checked out repositories. A possible implementation is to get
TSVNCache to record the repositories it's seen in the Registry, and
then run through them testing to see if they still exist when the
request is received. As I understand it, the URL gets passed to
TortoiseProc with /command:checkout. I can either modify the checkout
command, or add a new one for handling the URL which may be a bit
neater.

I presume that I can start coding by installing the latest Visual
Studio Express from http://msdn2.microsoft.com/en-us/express/
aa700735.aspx . I suspect my copy of Visual C++ 6.0 is a bit on the
old side, hopefully the new one won't clash.

Thanks for any pointers,

Ben

http://www.fluffy.co.uk/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tortoisesvn.tigris.org
For additional commands, e-mail: dev-help@tortoisesvn.tigris.org
Received on Thu Sep 6 18:00:51 2007

This is an archived mail posted to the TortoiseSVN Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.