I have a Subversion working copy where I made some local modifications to one file. The modifications are only relevant to me, I do not want to commit them. (The version in
For the last several years I have been using a simple solution which achieves exactly what you are looking for. It is called the NOCOMMIT keyword.
What I do is that I have a pre-commit hook in my SVN repository which checks to see whether any file contains the string NOCOMMIT, and if so, it fails the commit.
So, when a programmer makes a modification that should not be committed, (say, they changed the project-wide database connection string from the company-wide test server to their own local test server, or they added diagnostic debug statements that are going to be spamming the log with thousands of lines per second,) they append a //NOCOMMIT comment to it, and they do not have to worry about accidentally committing it. When the time comes to commit, they are prevented, so they are forced to either:
NOCOMMIT and remove any occurrences of it, thus hopefully fixing the code that they had attached it to.Personally, I find the NOCOMMIT keyword so useful that I use it even when working on pet projects of mine, where obviously, I am the only programmer in the team.
If you are using windows, you can paste the following text into file called pre-commit.bat in the hooks folder of your SVN repository.
:: Stops commits that contain the NOCOMMIT keyword.
setlocal
set REPOS=%1
set TXN=%2
SVNLook diff %REPOS% -t %TXN% | findstr /I /M /L NOCOMMIT > nul
if %errorlevel% gtr 0 (
exit 0
) else (
echo Your commit has been blocked because it contains the keyword NOCOMMIT. 1>&2
exit 1
)
On Unix systems, something like the following should do the trick, though please note that I have not tested it.
#!/bin/sh
REPOS="$1"
TXN="$2"
SVNLOOK=/usr/local/bin/svnlook
$SVNLOOK diff -t "$TXN" "$REPOS" | grep -i "NOCOMMIT" > /dev/null && { echo "Your commit has been blocked because it contains the keyword NOCOMMIT." 1>&2; exit 1; }