wiki:SvnRules

Version 1 (modified by tbretz, 11 years ago) ( diff )

--

Although the svn is a versioning system which keeps the history, it should be kept clean as much as possible. We are all humans, so we make mistakes, but svn should help us to cure real mistakes as fast as possible, not be sloppy and create more mistakes.

Here are a few simple rules which help a lot to make sure you know what you do when accessing the svn and which help you to properly document your changes. The later is important if a problems needs to be tracked. Not only the comments to the code of question might be important, but also other comments. To find the commit in question as soon as possible, comments which tells you the kind of the commit are very important (cosmetics, only includes, major code change, etc) and the meaning (fixed a compiler warning, fixed a memory leak, ...)

Comitting

Before you commit anything, check which files would be committed:

svn diff | grep Index

Now you have a list of files... choose the ones you want to submit and check the diff

svn diff filename

You might find surprises sometimes. A change you forgot or a change which was only for debugging. Clean your change. Now you are ready to commit the file

svn ci filename -m "Comment"

Write a comment which tells the type of change, the reason of change and maybe some details. Write comments for every change you made, try to be as detailed as possible. Hint: If you write a comment which needs the name of a file or class, most probably it is the wrong comment because it applies to another file.

Do that for each file independently, file by file. It is very rare that the same comment applies to several files. If this is the case, make sure that you checked all their diffs and then commit all of them together.

Revert

Sometimes it might happen that you committed something by mistake. For example, you thought to do svn ci filename but in fact did svn ci and committed file which were not intended to be committed. Don't forget to keep the list of files which need to be reverted as soon as possible before it is off your console history!

I have created a short script (I called it *revert.sh*) which allows to revert the last change (unfortunately only file-by-file, but this makes sense to ensure you know what you do).

svn merge -r COMMITTED:PREV $1
svn ci $1 -m "Reverting to last revision."
svn merge -r COMMITTED:PREV $1

Note: See TracWiki for help on using the wiki.