Tuesday, March 24, 2009

Better version of what I've said.

Since we're working in teams now with many people.  It is a good idea to start using branches.  The reason behind this is if you check out the trunk, some one else does as well, and then your 2 other team members and you all start commiting changes.  Horrible horrible collisions will occur.  So if someone modifies something and then commits it and you are using an older version and make your changes to something else, everything goes to hell and it becomes a nightmare.  With branches, you will always get a good working copy of the code.  And once you are finally done, then your changes can be merged with the trunk so the trunk stays at a constant working condition with no horrifying problems.  Trust me, this is much better than it sounds, it creates less headaches and easier to manage.  It is also a good way to fix bugs without messing everyone else up.  So here's the method to use:

Branch the trunk to start your work
Remember, this is not actually copying all the files in the repository, its mostly a database change, very little space consumed. This operation should be considered consuming almost no disk space, and you should feel free to make branches anytime. The alternative would be messed up merges, miscellaneously copied files and lost SVN commits which is unacceptable.
# svn copy -m "[Issue number] Branching to develop a fix for Issue number." http:/google/trunk http://google/branches/Issue number

Checkout your new branch
# svn co http://google/branches/Issue Number

Fix your bug
# cd Issue Number/
# svn status
# vi ..
# make
# cd source/
# svn status -q

Commit your changes to your branch
# svn commit -m "[Issue Number] Committing changes for review to my branch"
Adds/remove files and junk.
Transmitting file data ...........


Review
Damnit man, someone should check your code by easily checking out your branch.

Merging your branch back to the trunk
Change into your branch directory
# cd Issue Number/

Switch your branch to point to the trunk
# svn switch http://google/trunk
The only thing here should ONLY ONLY ONLY BE IS FILES BEING UPDATED. NOT ADDED.
Updated to revision 29242.

Find the r number from when the branch was created
# svn log --stop-on-copy http://google/branches/Issue Number
------------------------------------------------------------------------
r29130 | not this crap but bellow.

[TL-1788] Committing changes for review to my branch
------------------------------------------------------------------------
r29129 | stuff here.

[Issue Number] Branching to develop a fix for Issue number
------------------------------------------------------------------------

Find the r number of the trunk
# svn info
Path: .
URL: http://google/trunk
Repository Root: http://google/storage
Repository UUID: 0e262ef1-e203-0410-bf88-cba8cc7d4a2f
Revision: 29242
Node Kind: directory
Schedule: normal


Merge the branch to the trunk
# svn merge -r29129:29242 http://google/branches/Issue Number

Look at your changes, now merged into the trunk
# svn status -q
# cd source

Commit those changes, if no conflicts, to the trunk
# svn commit -m "[Issue Number] Checking in fix for blah... to trunk"
...
Transmitting file data ...........
Committed revision 28953.



Remove your old branch
# svn delete -m "[Issue Number] Removing development branch" http://google/branches/Issue Number


No comments:

Post a Comment