By this time Harry is back from his tea and is ready to create a working copy and start coding.
~ harry$ svn checkout svn://server.futilisoft.com/lottery Checked out revision 0.
Harry wonders if Sally has already done anything in the new repository.
~ harry$ cd lottery lottery harry$ ls -al total 0 drwxr-xr-x 3 harry staff 102 Apr 6 11:40 . drwxr-xr-x 3 harry staff 102 Apr 6 11:40 .. drwxr-xr-x 7 harry staff 238 Apr 6 11:40 .svn
Apparently not. Nothing here but the .svn
administrative area.
Jolly good then. It’s time to start coding. He opens his text editor and
creates the starting point for their product.
#include <stdio.h> #include <stdlib.h> int calculate_result(int white_balls[5], int power_ball) { return 0; } int main(int argc, char** argv) { if (argc != 7) { fprintf(stderr, "Usage: %s power_ball (5 white balls)\n", argv[0]); return -1; } int power_ball = atoi(argv[1]); int white_balls[5]; for (int i=0; i<5; i++) { white_balls[i] = atoi(argv[2+i]); } int result = calculate_result(white_balls, power_ball); printf("%d percent chance of winning\n", result); return 0; }
Typical of most initial implementations, this is missing a lot of features. But it’s a good place to begin. Before committing his code, he wants to make sure it compiles and runs.
lottery harry$ gcc -std=c99 lottery.c lottery harry$ ls -l total 32 -rwxr-xr-x 1 harry staff 8904 Apr 6 12:15 a.out -rw-r--r-- 1 harry staff 555 Apr 6 12:15 lottery.c lottery harry$ ./a.out Usage: ./a.out power_ball (5 white balls) lottery harry$ ./a.out 42 1 2 3 4 5 0 percent chance of winning
Righto. Time to store this file in the repository. First Harry needs to add the file to the pending changeset.
lottery harry$ svn add lottery.c A lottery.c
Harry uses the status operation to make sure the pending changeset looks proper.
lottery harry$ svn status ? a.out A lottery.c
Subversion is complaining because it doesn’t know what to do about
that a.out
file. That’s a compiled
executable, which should not be stored in a version control repository.
Keep calm and carry on. Now
it’s time to commit the file.
lottery harry$ svn commit -m "initial implementation" Adding lottery.c Transmitting file data . Committed revision 1.