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

Re: Implementing custom context menu entries and extending tsvn: url scheme hander

From: Stefan Küng <tortoisesvn_at_gmail.com>
Date: 2007-09-06 20:18:20 CEST

Ben Summers wrote:

>> But much easier to do: a simple registry entry can already show a
>> context menu, even without a shell extension. Just read the docs in the
>> MSDN.
>> As an example, think of all the text editors which add an 'open with
>> mytexteditor' for every file. You could write a small program or even
>> script which would create the URL to open from the selected file and
>> then open the browser - that could be implemented in a few minutes.
>
> You are indeed correct.
>
> The only way I can see to find the URL given a file on disc is to use
> SubWCRev with an input file of $WCURL$ and then read the output file. It
> does work, but is there a more elegant way without installing a separate
> SVN binary?

If you use a current nightly build, you can use the COM object SubWCRev
provides to fetch the URL of a file.
An example jscript would look like this:

--------------
var objArgs,num;

objArgs = WScript.Arguments;
num = objArgs.length;
if (num != 1)
{
     WScript.Echo("invalid arguments passed");
     WScript.Quit(1);
}
var filepath = objArgs(0);
filesystem = new ActiveXObject("Scripting.FileSystemObject");

subwcrevObject = new ActiveXObject("SubWCRev.object");

subwcrevObject.GetWCInfo(filepath, 1, 1);

WScript.Echo("the URL of the file " + filepath + " is " + \
                subwcrevObject.Url);

--------------

Instead of showing a dialog with the URL, you could start the web
browser with the url. That's all you have to do (apart from creating the
registry entries to get the menu).

Have a look at the test script for the SubWCRev COM object:
http://tortoisesvn.tigris.org/svn/tortoisesvn/trunk/src/SubWCRev/testCOM.js
(username: "guest", leave password empty)

>> > 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.
>>
>> What happens if someone has the same folder checked out twice? Which
>> location would you then use?
>>
>> Since this operation won't happen very often, it wouldn't matter if it
>> would take a few seconds to find the file from the URL. So I guess a new
>> function in the cache which would find a local path for a given URL
>> would do the trick here. But the problem persists: what to do when an
>> URL matches multiple local paths?
>
> I suppose you give them a choice in a pop up dialogue. In this
> particular use case they're unlikely to have multiple checkouts, but
> obviously this is common for developers.

That dialog would look really ugly if there are 5 or more files with the
same url from which the user would have to choose from :)

>> > 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.
>>
>> VSExpress won't do the trick here, sorry. Because the express edition
>> doesn't come with the MFC/ATL libraries which we use in TSVN.
>> You can only compile some sub projects of TSVN with the express edition:
>> TortoiseBlame, CrashRpt, ResText, SubWCRev, TortoiseIDiff, TortoiseUDiff.
>>
>> You will need the professional edition of VS to compile TSVNCache and
>> TortoiseProc.
>
> That's a helpful omission from Microsoft.

Well, they're giving the express editions away for free. You can't blame
them for trying to urge people to buy the professional version if they
want to use their libraries too.

> It sounds like the best way forward is for me to implement the features
> outside TortoiseSVN, then perhaps release them as an separate add-on. If
> there's any interest they could be implemented nicely inside TSVN later.
>
> Thanks for your help! You've probably saved me a lot of work by
> suggesting something isn't done.

The first feature is almost done - just extend the jscript a little bit
and create the registry entries.

The second feature would require an enhancement of the cache.

Stefan

-- 
        ___
   oo  // \\      "De Chelonian Mobile"
  (_,\/ \_/ \     TortoiseSVN
    \ \_/_\_/>    The coolest Interface to (Sub)Version Control
    /_/   \_\     http://tortoisesvn.net
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tortoisesvn.tigris.org
For additional commands, e-mail: dev-help@tortoisesvn.tigris.org
Received on Thu Sep 6 20:15:07 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.