SVN Change Lists – Like GIT Staging
I have been embedded into an existing development team for a month contract, and doing so means returning to using SVN for version control. Larger businesses find it difficult to change systems, and step into the future, or even today – IE8 is a great example of this lack of change. New infrastructure is always time consuming to implement when the old works. And SVN seems so old now, compared to GIT.
This time I have been using SVN from the CLI, which I didn’t do last time. In the past I had used TortiseSVN for handling commits, but the linear commit to a shared repository has limitations after using GIT for a few years.
One little trick that I have picked up this time, is using Change Lists. It is a essentially the ‘staging’ feature used in GIT. which means making commits to smaller collections of files, in the midst of a lot of changes, can be done.
What is done:
First you create a list of changes
svn changelist foo mydir/dir1/file1.c mydir/dir2/myfile1.h
svn changelist foo mydir/dir3/myfile3.c etc.
Then you can view the files assigned to the Change List:
$ svn status
? mydir/frank.appcache
M mydir/dir1/main.js
--- Changelist 'foo':
M mydir/dir1/file1.c
A mydir/dir2/myfile1.h
A mydir/dir3/myfile3.c
Then commit the changes in the change list
svn commit -m "Commit message in here." --changelist foo
## Remove Items from Change List
If there is a file added to the Change List that should be removed, then just use:
svn changelist --remove
## Bonus Points
Using the option `–keep-changelists` will allow you to build a list of files, with an assigned change list, and will keep the list after the commit. This way you could create a reusable change list, for example of less files, that can be reused in commits without having to build the list each time.
svn changelist bar mydir/dir1/file1.c mydir/dir2/myfile1.h --keep-changelists
Notes
- Change lists can be assigned only to files—Subversion doesn’t currently support the use of changelists with directories.
They only apply to your local machine, they are not pushed into the repository in a collection.
Further Reading
View the documentation.