If like me you do a lot of your SVN work in the command line you will be familiar with the SVN status codes, you know when you do an svn status you see a list of files, some have been modified (M), some have been added (A), and other are well in a state of limbo (!).
This is a quick explanation of most of the codes and what it means to your the user if you see them
For those of you who use a nice GUI to manage your working copies, Look Away Now
>svn status ? file1.txt ! file2.txt A file3.txt M file4.txt A+ file5.txt G file6.txt C file7.txt D file8.txt U file9.txt ...
So the above console output isn’t quite what you would see every day but it illustrates most of the status codes you will run in to when working with your working copy from the command line.
? – This file is not under version control
As the sumary suggests the ? code is SVN’s way of telling your that a file exists in the working copy that isn’t under version control and as such will not be send to the server on the next commit.
If you want to add a file you will do use the svn add command
svn add file1.txt
There are many cases when you don’t want a file to be under version control for instance if tis a config file that contains passwords, in this case you can tell svn to ignore the file using the svn:ignore property like so:
svn propedit svn:ignore
A – This file will be added to version control, after the commit
you have done an svn:add already and this file is going to be part of the next commit
! – This file is under version control but is missing from the working copy
I see this all the time, and can happen in a number of scenarios but its basically svn’s way of telling you that a file that should be in the working copy isnt!
This usually happens when you (or your editor) removes a file but does not tell svn, to delete a file the correct way you must submit an svn delete command
svn delete file1.txt
However this will only work if the file is still there, in the scenario where it has been removed and svn is showing a ! in the status, you can force delete it with :
svn delete file1.txt --force
M – Working copy has been modified
This is the most common status code on an active project, its simply means that a file has been modified and the updated version will be committed next time you do a commit.
G – Changes on the repository were automatically merged into the working copy
You will see this when you do an update (svn up) rather that a status but its important all the same, svn is telling you that is automatically merged changes that somebody else has made into your working copy, In most cases this is a good queue to re-test your own changes (or run that test suite again).
C – Changes on the repository could not be merged in the working copy, manual intervention required
Like G this is svn’s way of telling you that changes exist on the server but unlike G the svn client was not able to automatically merge in the changes, its now up to you the developer with the assistance of the developer who made the change in the repository to collaborate and decide which lines of code stay and which ones go.
As of svn version 1.5 interactive conflict resolution was introduced which will allow you to resolve conflicts when you perform an SVN up, providing you have the SVN_EDITOR environment variable set you can open the effected file and see the conflict:
-Just buy a sandwich.+<<<<<<< .mine+Go pick up a cheesesteak.+=======+Bring me a taco!+>>>>>>> .r32blah blah blah...
I will write a detailed article about conflict resolution in a later post as it is somewhat out of the scope of this brief guide but for now I would suggest you look at the SVN book for further details.
There are many more status codes, and I welcome your comments on them but for me these are the ones I come across most in my travels and from 2 years of manning the Code Spaces support desk these are the ones that catch out users who are new to Subversion.
