Wikia

Delphi Programming

Adding TortoiseSVN to the Tools menu

Talk1
2,909pages on
this wiki

The Tools Menu of the Delphi IDE allows you to add additional items. In this article you will learn how to add entries for calling some TortoiseSVN commands.

BasicsEdit

TortoiseSVN comes with a tool TortoiseProc which allows you to call the various commands using the commandline.

There is one particular oddity to be aware of: If you get an "Access to <directory> was denied" you forgot to specify the /notempfile option.

The Delphi IDE allows adding custom entries to the Tools menu that can contain macros that will be resolved when the entry is selected.

PreparationsEdit

The Delphi IDE has got a bug resolving macros if these are not preceded by a space, e.g. /path:$path($project)) will not be resolved. This is quite annoying but we can work around it by using a batch file like this:

@ECHO OFF
rem This is a workaround for the Delhi IDE's bug
rem to not resolve macros if they are part of
rem a "word" e.g.:
rem /path:$path($project))
rem is not resolved
start "TortoiseSVN" "c:\Program Files\TortoiseSVN\bin\TortoiseProc.exe" /notempfile /command:%1 /path:%2

Put this batch file whereever you like it, e.g. to c:\bin\svn-cmd.cmd. You will need to specify the full path to it when you add entries to the tools menu.

The batch requires two parameters:

  • The command to execute, e.g. commit, update
  • The directory on which to execute the command

Adding a Commit entryEdit

The first item we will add is a SVN Commit Project entry:

  1. Select Tools / Configure Tools ... to open the Tool Options Dialog
  2. Press Add to open the Tool Properties dialog
  3. Enter "SVN Commit Project" as the Title
  4. Enter "c:\bin\svn-cmd.cmd" as Program
  5. Leave Working dir empty
  6. Enter "commit $PATH($PROJECT) $SAVEALL" as Parameters
  7. Press OK and Close to leave the dialogs

Now there is an entry SVN Commit Project in the tools menu. When you select it, it will call the commit dialog of TortoiseSVN as if you right clicked on the directory and selected commit from the context menu.

Of course this works only if the directory contains source code that was previously checked out of a Subversion repository.

Adding an Update entryEdit

Now we will add an SVN Update Project entry. Basically this just replaces the commit command with the update command:

  1. Select Tools / Configure Tools ... to open the Tool Options Dialog
  2. Press Add to open the Tool Properties dialog
  3. Enter "SVN Update Project" as the Title
  4. Enter "c:\bin\svn-cmd.cmd" as Program
  5. Leave Working dir empty
  6. Enter "update $PATH($PROJECT) $SAVEALL" as Parameters
  7. Press OK and Close to leave the dialogs

Adding a Check entryEdit

The last entry we want to add is "SVN Check Project" which will check for modified files. Again, this just replaces the command with repostatus:

  1. Select Tools / Configure Tools ... to open the Tool Options Dialog
  2. Press Add to open the Tool Properties dialog
  3. Enter "SVN Project" as the Title
  4. Enter "c:\bin\svn-cmd.cmd" as Program
  5. Leave Working dir empty
  6. Enter "repostatus $PATH($PROJECT) $SAVEALL" as Parameters
  7. Press OK and Close to leave the dialogs

Adding a Browse entryEdit

Ok, I lied, we will add another entry: "SVN Browse Project" which opens the repository browser for the current project. We don't really need the $SAVEALL macro here but just in case we add it anyway.

  1. Select Tools / Configure Tools ... to open the Tool Options Dialog
  2. Press Add to open the Tool Properties dialog
  3. Enter "SVN Project" as the Title
  4. Enter "c:\bin\svn-cmd.cmd" as Program
  5. Leave Working dir empty
  6. Enter "repobrowser $PATH($PROJECT) $SAVEALL" as Parameters
  7. Press OK and Close to leave the dialogs

Diff the topmost editor fileEdit

To view a diff of the current topmost editor file, add a new tools entry with the following settings:

  1. Set title to: "SVN Diff"
  2. Set program to: "c:\bin\svn-cmd.cmd"
  3. Set Parameters to: "diff $EDNAME $SAVE"

Log of the topmost editor fileEdit

To show the log of the current topmost editor file, add a new tools entry with the following settings:

  1. Set title to: "SVN Log"
  2. Set program to: "c:\bin\svn-cmd.cmd"
  3. Set Parameters to: "log $EDNAME $SAVE"

External LinksEdit

Around Wikia's network

Random Wiki