Friday, October 9, 2009

Subversion and the Sandwich Recipe

Here, two programmers are collaborating on a sandwich recipe. One programmer makes a sandwich folder and a subversion (SVN) repository. In step 3 he enters his recipe then he imports that source file into the repository.
 
mkdir sandwich
svnadmin create sandwichrepo
copy con sandwich\recipe.txt
2 slices oat bread
honey dijon mustard
smoked turkey
lettuce
tomato
F6
    1 file(s) copied.
 
svn import sandwich file:///c:/sandwichrepo/sandwichproject -m "inital import"
 
svn list file:///c:/sandwichrepo/sandwichproject
Now, simulate another programmer by creating a folder for his work. This programmer checks out the sandwich project which creates a folder named sandwichproject. He modifies the text of the recipe using Notepad then verifies his differences and commits his changes.
mkdir otherprogrammer
cd otherprogrammer
svn co file:///c:/sandwichrepo/sandwichproject
cd sandwichproject
notepad recipe.txt <>
 
svn status -u
M     1 recipe.txt
 
svn diff recipe.txt
=================================
--- recipe.txt  (revision 1)
+++ recipe.txt  (working copy)
@@ -1,4 +1,4 @@
-2 slices oat bread
+2 slices wonder bread
 honey dijon mustard
 smoked turkey
 lettuce
 
C:\otherpgmr\sandwichproject>svn commit -m "Oat bread?  Yuck!"
Sending        recipe.txt
Transmitting file data .
Committed revision 2.
Nov 3 - another view - Instant Subversion