Thursday, 12 September 2013

Temporarily ignore some files with subversion. global-ignores, svn:ignore property and bash functions to add and remove elements from global-ignores

How might we temporarily ignore some files with subversion.
e.g. when doing a particular type of merge or svn diff/status

There is not an svn command-line option to do this.
Setting svn:ignore property on directory would work, but it is easier to put in a temporary global ignore.


Setting svn:ignore property on directory would work, but ...
http://svnbook.red-bean.com/en/1.7/svn.advanced.props.special.ignore.html
svn propedit svn:ignore .

It is easier to put in a temporary global ignore.
http://svnbook.red-bean.com/en/1.7/svn.advanced.confarea.html
edit your ~/.subversion/config file, uncomment and change the global-ignores list
global-ignores = *.o *.log
Some bash functions so adding and removing these global ignores can be automated:

function svnAddToGlobalIgnores {
 SVNGI=$(grep global-ignores ~/.subversion/config  |grep -v ^#)
 if [[ "$SVNGI" == "" ]] ; then
    echo "" >> ~/.subversion/config
    echo "global-ignores = $*" >> ~/.subversion/config
 else
    sed -ibak "s/^\(global-ignores.*\)$/\1 $*/" ~/.subversion/config
 fi
 grep global-ignores ~/.subversion/config
}
function svnRmFromGlobalIgnores {
 SVNGI=$(grep global-ignores ~/.subversion/config  |grep -v ^#)
 if [[ "$SVNGI" == "" ]] ; then
    echo "nothing to do"
 else
    for f in $*; do 
        sed -irmbak "s/^\(global-ignores.*\)$f\(.*\)$/\1\2/" ~/.subversion/config
    done
 fi
 grep global-ignores ~/.subversion/config
}

Usage:
svnAddToGlobalIgnores ReleaseNotes.txt ReleaseDiff.log modulerelease.tcl
svn merge $SVNREINT $SVNURLFROM
svnRmFromGlobalIgnores ReleaseNotes.txt ReleaseDiff.log modulerelease.tcl

No comments: