0

I wrote a batch script, which is branching my project for svn and want to create docs with sphinx which I then copy into the branched path.

The part where I do this is:

ECHO ##### Creating Docs Branch %VERSION%

cd %~dp0\trunk\Python\MyPackage\docs
call make html
cp -r _build\html %~dp0\branches\%VERSION%\Python\docs\MyPackage

svn add %~dp0\branches\%VERSION%\Python\docs\MyPackage
svn commit %~dp0\branches\%VERSION%\Python\docs\MyPackage -m "Added Docs Branch %VERSION%"

This fails with cp: cannot mkdir "D:/00_Workspace/MyProject/MyPackage//branches/1.1.0/Python/docs/MyPackage": Path could not be found

Apparently there is a second / added between MyPackage and branches Why does this happen?

Here is the full version of the batch

@echo off
set "VERSION=%1"
set "COMMON_VERSION=%2"

if "%VERSION%"=="" set /p VERSION=Enter the version number you want to create the branch for?: 
if "%COMMON_VERSION%"=="" set /p COMMON_VERSION=Enter the version number of the common python toolchain you want to use?: 

set PACKAGE_NAME=%~dp0

ECHO ##### Updating SVN Repository

svn update

ECHO ##### Creating requirements.txt
cd trunk
call python create_requirements_txt.py %VERSION% %COMMON_VERSION%
svn add requirements.txt
svn commit requirements.txt -m "Updated requirements.txt to version %VERSION%"
cd %~dp0

ECHO ##### Creating Branch for version %VERSION%

for /f "delims=" %%i in ('svn info ^| FINDSTR /R /C:"Relative URL"') do set URL=%%i
set "URL=%URL:*: =%"

for /f "delims=" %%i in ('svn info ^| FINDSTR /R /C:"Repository Root"') do set ROOT=%%i
set "ROOT=%ROOT:*: =%"

set "DEST_URL=%ROOT%%URL:*\trunk=%/branches/%VERSION%"
set "SRC_URL=%ROOT%%URL%/trunk"

ECHO ##### Package: %PACKAGE_NAME%
ECHO ##### Source: %SRC_URL%
ECHO ##### Destination: %DEST_URL%

call svn copy %SRC_URL% %DEST_URL% -m "Branch %PACKAGE_NAME% Version %VERSION%"

ECHO ##### Succesfully created branch %VERSION%
call svn update

ECHO ##### Creating Docs Branch %VERSION%

cd %~dp0\trunk\Python\MyPackage\docs
call make html
cp -r _build\html %~dp0\branches\%VERSION%\Python\docs\MyPackage

svn add %~dp0\branches\%VERSION%\Python\docs\MyPackage
svn commit %~dp0\branches\%VERSION%\Python\docs\MyPackage -m "Added Docs Branch %VERSION%"
pause
exit /b 0

:SVN_ERROR
ECHO ##### SVN Error: Either Source Repo (%SRC_URL%) does not exist or the Tag (%DEST_URL%) already exists!
pause
exit /b 1
1
  • %~dp0 contains drive letter plus path from where script is run ended with backslash. change svn add %~dp0\branches\%VERSION%\Python\docs\MyPackage with svn add %~dp0branches\%VERSION%\Python\docs\MyPackage and all similar paths. Aug 1, 2017 at 9:57

1 Answer 1

1

As @elzooilogico said

%~dp0 contains drive letter plus path from where script is run ended with backslash. change svn add %~dp0\branches\%VERSION%\Python\docs\MyPackage with svn add %~dp0branches\%VERSION%\Python\docs\MyPackage and all similar paths.

that should work.

1
  • 1
    I typically assign %~dp0 to a local environment variable and strip off the trailing backslash. It's easier for me to read %SCRIPT_DIR%\branches\....
    – Eryk Sun
    Aug 1, 2017 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.