blog.jj5.net (2003 to 2005)

Force automatic subversion working copy recursive file addition from the command-line

Wed Feb 23 07:14:00 UTC+1100 2005

Categories:

...with a temporary config file and global-ignore pattern.

Basically, something like this will get you off the ground:

F:\file\test>echo [miscellany] > config & echo global-ignores = *.exe >> config & svn add . --config-dir . --force

Then all you need to do is fix up the actual paths, put the temp config file somewhere outsite the current directory, and perhaps create a batch file that takes a PATH arg, something like this [1].

Handy!

John.

p.s. If you're interested I maintain my most 'current' svn ignore list here: http://blog.jj5.net/files/programming/dev/svn-exclude.txt

[1] svn-force-add.cmd

@call F:\file\proj\net.jj5\utility\command-line\dev\0.10\cm-deploy-beta.cmd
rem @echo OFF

rem ///////////////////////////////////////////////////////////////////////
rem // svn-force-add
rem // ====================================================================
rem //
rem // Recursively add all files that don't match the exclusion pattern.
rem //
rem // File addition begins in the current directory.
rem //

rem set DEBUG=1

goto :INIT


rem ///////////////////////////////////////////////////////////////////////
rem // HELP procedure
rem // Display brief help message
rem //

:HELP

 if defined TRACE %TRACE% [proc %0 %*]
 
 echo svn-force-add PATH
 echo.
 echo  Adds files that don't match the exclusion pattern to subversion.
 echo.

goto :EOF


rem ///////////////////////////////////////////////////////////////////////
rem // MAIN procedure
rem //

:MAIN

 if defined TRACE %TRACE% [proc %0 %*]

  set _ConfigDir=%TEMP%\svn-config
 set _ConfigFile=%_ConfigDir%\config
 set _GlobalIgnoreFile=o:\programming\dev\svn-exclude.txt

 if not exist "%_ConfigDir%" mkdir "%_ConfigDir%"

 echo [miscellany] > "%_ConfigFile%"
 type "%_GlobalIgnoreFile%" >> "%_ConfigFile%"

 svn add . --config-dir "%_ConfigDir%" --force

 del "%_ConfigDir%" /f /q

goto :EOF


rem ///////////////////////////////////////////////////////////////////////
rem // INIT procedure
rem //

:INIT

@if not "%ECHO%"=="" echo %ECHO%
@if not "%OS%"=="Windows_NT" goto DOSEXIT

rem Set local scope and call MAIN procedure
 
setlocal & pushd & set RET=

 set SCRIPTNAME=%~n0
 set SCRIPTPATH=%~f0
 
 if "%DEBUG%"=="1" (set TRACE=echo) else (set TRACE=rem)
 
 call u:\utility\ntscriptlib-0.10\ntscriptlib.bat :INIT %SCRIPTPATH%

 if /i {%1}=={/help} (call :HELP %2) & (goto :HELPEXIT)
 if /i {%1}=={/?} (call :HELP %2) & (goto: :HELPEXIT)

 call :MAIN %*

 :HELPEXIT

 popd & endlocal & set RET=%RET%

goto :EOF


rem ///////////////////////////////////////////////////////////////////////
rem // ERROR procedure
rem // Abnormal exit
rem //

:ERROR

 if defined TRACE %TRACE% [proc %0 %*]
 
 echo.
 echo WARNING: Script failed with errorlevel: %ERR%
 echo.
 echo   Current directory is:
 echo     %CD%
 echo   Command-line was:
 echo     %CMDCMDLINE%
 echo.

goto :EOF


rem ///////////////////////////////////////////////////////////////////////
rem // DOSEXIT
rem // ====================================================================
rem //
rem // These must be the final lines in the script.
rem //

:DOSEXIT

 echo This script requires Windows NT or later.

rem ///////////////////////////////////////////////////////////////////////


Copyright © 2003-2005 John Elliot