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

Re: Feature request: SVNLinks

From: the-moog <jason.morgan_at_cropwell.net>
Date: Tue, 9 Sep 2008 08:21:23 -0700 (PDT)

Of course I could use the SVN API, that is not the point, so could
anybody else yet they still install Tortoise.
The SVN command line tools are not integrated into the Windows UI,
that is the point of Tortoise; Friendlyness and no need to install SVN
on the client.
I have to get SVN adopted in such a way that its simple, i.e. it's all
in one place. Ideally, nothing more than TSVN to install.
Indeed the batch file below got a long way to that goal, but its still
detached from Tortoise.
I would not seriously consider that developers would add a feature if
I were the only one to benefit. Indeed if I have VC8 I'd add it
myself.
My initial suggestion was SVNLinks and I'd love it if Tortoise
developers simply adopted this idea, indeed I have discovered you
almost already have with tsvn:, but this became more generic, plugins
are the way to go.
In any case, I can't be the only person who wants to add functionality
to Tortoise that is why I suggested a means of adding third party apps
to the context menu, rather than banging on about my organisations
particular use of it.

To correct a later misunderstanding:
The batch file would be the output of the context menu, not the input.
My use is analagous to the TortoiseSVN->Export, except that a file is
created in the export that links the exported files to the original
repository.
Clicking that file (or in this case, a batch file in the same location
that processes it) results in the origial repository being opened.
Because tsvn: links can't do much the batch file is currently required
to do extra processing. Though it does mean it works regardless of if
SVN or TSVN is installed on the client's machine, and instructs the
user to install one or the other if they are both missing. (obviosuly
it is impossible for tsvn: to do that)

Perhaps it would make more sense if I simply gave an example:
A person, who does not have SVN or TSVN finds the attached two files
in a folder of a foreign repository (MKS in this case)
They click the file as requested, and as a result get the files from
the repo, the controlled file in the foreign system is the .url file.
If they click the file and don't have SVN or TSVN, they get
instructions on how to install one or the other.

Similarly, a developer wants to place something they have been working
on in SVN in to MKS. Instead of exporting everything, loosing the
history,
they simple do TortoiseSVN->"Export Link" to create the attached two
files in the target location. The command "Export Link" would be a
plugin.

Over time, this same simple scheme could be used to usurp any foreign
VCS without any need for subversion to have a converter for it!!

To use this code, simply change the link URL to point to a sensible
URL in your scheme.
-----------------------------------------
CODE: This folder is archived in SVN - Run Me To Checkout.bat
----------------------------------------
@echo off
set URL=http://
set SVNEXE=svn.exe
set TSVNEXE=tortoiseproc.exe

for /f "delims=" %%X in ('cd') do set CURDIR=%%X
set LOGFILE="%CURDIR%\MKSSVN_log.txt

if not exist "%CURDIR%"\SVNLink.url goto NOURLERR
for /F "usebackq" %%X in ("%CURDIR%\SVNLink.url") do for /F "delims==
tokens=1,2" %%Y in ("%%X") do if "%%Y"=="URL" SET %%Y=%%Z

REM we support tsvn links by removing the prepended tsvn: as this
script has no need for them
set URL=%URL:tsvn:=%

REM we support a given version using a bookmark in the URL
for /F "delims=# tokens=1,2" %%x in ("%URL%") do set WCREV=%%y
if not "%WCREV%"=="" for /F "delims=# tokens=1,2" %%x in ("%URL%") do
set URL=%%x

REM echo URL=%URL%
REM pause

CALL :LOG -------------
CALL :LOG %TIME% %DATE%
CALL :LOG Running in %CURDIR%
CALL :LOG .
CALL :LOG Checking out %URL%
if "%WCREV%" GTR "0" CALL :LOG Checkout revision %WCREV%
if "%WCREV%"=="" CALL :LOG Checking out HEAD revision
CALL :LOG .

set SVNPATH="NUL"
set TSVNPATH="NUL"

REM
---------------------------------------------------------------------
REM Search for required programs
for /f %%X in ("%SVNEXE%") do set SVNPATH=%%~dp$PATH:X
for /f %%X in ("%TSVNEXE%") do set TSVNPATH=%%~dp$PATH:X
if exist "%SVNPATH%" CALL :LOG SVN found in %SVNPATH%
if exist "%TSVNPATH%" CALL :LOG TortoiseSVN found in %TSVNPATH%

if "%TSVNPATH%"=="NUL" if "%SVNPATH%"=="NUL" GOTO NOSVNERR

REM Prefer TortoiseSVN
if NOT "%TSVNPATH%"=="NUL" GOTO USETSVN
REM use SVN if Tortoise does not exist
if NOT "%SVNPATH%"=="NUL" GOTO USESVN

REM Should never get here
GOTO PROCERR

REM
---------------------------------------------------------------------
REM Script that uses TSVN to check out URL to current folder
:USETSVN
set REVCMD=
if "%WCREV%" GTR "0" set REVCMD=/revision:%WCREV%
SET WVPATH=%CURDIR%
CALL :LOG Using TortoiseSVN
CALL :CHECKTARGET
if NOT "%WVPATHOK%"=="TRUE" GOTO EXIT
CALL :LOG Good, target folder passes write test
CALL :LOG Checking out %URL% to %WVPATH%
REM start /b iexplore tsvn:%URL%
"%TSVNPATH%%TSVNEXE%" /command:checkout /path:"%WVPATH%\." /url:"%URL
%" %REVCMD%
CALL :LOG Done.
GOTO EXIT

REM
---------------------------------------------------------------------
REM Script that uses SVN to check out URL to current folder
:USESVN
set REVCMD=
if "%WCREV%" GTR "0" set REVCMD=--revision %WCREV%
CALL :LOG Using SVN client
CALL :CHECKTARGET
if NOT "%WVPATHOK%"=="TRUE" GOTO EXIT
CALL :LOG Good, target folder passes write test
CALL :LOG Checking out %URL% to %WVPATH%
for /f %%X in ('svn --version --quiet') do SET SVNVER=%%X
for /f "delims=. tokens=1" %%x in ("%SVNVER%") do SET SVNVERMAJ=%%x
for /f "delims=. tokens=2" %%x in ("%SVNVER%") do SET SVNVERMIN=%%x
for /f "delims=. tokens=3" %%x in ("%SVNVER%") do SET SVNVERREL=%%x

if "%SVNVERMAJ%" GEQ "1" if "%SVNVERMIN%" GEQ "5" if "%SVNVERREL%"
GEQ "0" GOTO SVNVEROK
GOTO SVNVERR

:SVNVEROK
echo SVN Version %SVNVER% is sufficient

echo.
echo Enter path for file working version [press enter to select
default]
echo Default=%CURDUR%
set WVPATH=
set /p WVPATH=:
if /i "%WVPATH%" EQU "" SET WVPATH=%CURDIR%

"%SVNPATH%%SVNEXE%" co %REVCMD% --depth empty "%URL%" "%WVPATH%"
if NOT ERRORLEVEL 0 CALL :LOG Error %ERRORLEVEL% running "%SVNPATH%
%SVNEXE%" co --depth empty "%URL%" "%WVPATH%"
if ERRORLEVEL 0 CALL :LOG SVN completed successfully
GOTO EXIT

REM
---------------------------------------------------------------------
REM Logging function
:LOG
if "%1"=="." ECHO. >> %LOGFILE%
if NOT "%1"=="." ECHO %* >> %LOGFILE%
GOTO EXIT

REM
---------------------------------------------------------------------
REM Function to check if a folder is writable
:CHECKTARGET
dir /d "%WVPATH%\" >NUL 2>NUL
if "%ERRORLEVEL%" GEQ "1" mkdir %WVPATH%
dir /d "%WVPATH%\" >NUL 2>NUL
if "%ERRORLEVEL%" GEQ "1" goto PATHERR

for /f "delims=/ tokens=1,2,3" %%x in ("%DATE%") do SET TFDATE=%%x%%y%
%z
for /f "delims=: tokens=1,2,3" %%x in ("%TIME%") do SET TFTIME=%%x%%y%
%z

SET TEMPFILE=%TFDATE%%TFTIME%%RANDOM%.txt

echo "I am a temporary file, you may delete me" > "%WVPATH%"\%TEMPFILE
%
if not exist "%WVPATH%"\%TEMPFILE% goto PATHERR
set WVPATHOK=TRUE
del "%WVPATH%"\%TEMPFILE%
GOTO EXIT

REM
---------------------------------------------------------------------
:SVNVERR
CALL :LOG SVN Version needs to be greater than 1.5.0
GOTO EXIT

:NOURLERR
CALL :LOG SVNLink.url file missing, this file tells me what repository
path to use
GOTO EXIT

:PROCERR
CALL :LOG Batch file error, consult Jason Morgan
GOTO EXIT

:NOSVNERR
CALL :LOG SVN and/or TortoiseSVN must be installed
CALL :LOG http://tortoisesvn.tigris.org/
CALL :LOG and
CALL :LOG http://subversion.tigris.org/
GOTO EXIT

:PATHERR
echo Could not create working version path - Write Error?
GOTO EXIT

REM
---------------------------------------------------------------------
set URL=
set SVNEXE=
set TSVNEXE=
set LOGFILE=
set SVNPATH=
set TSVNPATH=
set WVPATH=
set WVPATHOK=
set TFDATE=
set TFTIME=
set TEMPFILE=
set REVCMD=
set WCREV=
:EXIT

----------------------------
CODE: SVNLink.url
-----------------------------
[DEFAULT]
BASEURL=tsvn:http://localhost/svn/test/datasheets
[InternetShortcut]
URL=tsvn:http://localhost/svn/test/Datasheets#10
IDList=
HotKey=0

[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,0

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_tortoisesvn.tigris.org
For additional commands, e-mail: dev-help_at_tortoisesvn.tigris.org
Received on 2008-09-09 17:37:50 CEST

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