Lock, Revert

Fed up with conflicts, Sally decides to lock pb.c so only she can modify it.

trunk sally$ svn lock pb.c
'pb.c' locked by user 'sally'.

Harry does an update.

trunk harry$ svn update
U    pb.c
D    libvmime-0.9.1
Updated to revision 11.

trunk harry$ ls
Makefile    pb.c

trunk harry$ ls -l
total 16
-rw-r--r--  1 harry  staff    58 Apr  7 08:13 Makefile
-rw-r--r--  1 harry  staff  1121 Apr  7 08:51 pb.c

Blast! That daft Sally deleted all his email code! Harry decides to indent[14] pb.c.

trunk harry$ indent pb.c

trunk harry$ svn st
?       pb.c.BAK
M       pb.c

trunk harry$ svn commit -m "indent pb.c"
Sending        trunk/pb.c
Transmitting file data .svn: Commit failed (details follow):
svn: User harry does not own lock on path '/trunk/pb.c' (currently locked by sally)

What a kerfuffle. Harry reverts the changes.

trunk harry$ svn revert pb.c
Reverted 'pb.c'

trunk harry$ svn st
?       pb.c.BAK

trunk harry$ rm pb.c.BAK 

Sally, basking in the comfort of her lock, makes her edits. She has decided to eliminate uses of atoi(), which is deprecated.

trunk sally$ svn diff
Index: pb.c
===================================================================
--- pb.c    (revision 10)
+++ pb.c    (working copy)
@@ -43,7 +43,14 @@
     int white_balls[5];
     for (int i=0; i<5; i++)
     {
-        white_balls[i] = atoi(argv[1+i]);
+        char* endptr = NULL;
+        long val = strtol(argv[1+i], &endptr, 10);
+        if (*endptr)
+        {
+            fprintf(stderr, "Invalid arguments\n");
+            return -1;
+        }
+        white_balls[i] = (int) val;
     }
 
     int result = calculate_result(white_balls, power_ball);

trunk sally$ make
gcc -std=c99 -Wall -Wextra -Werror pb.c -o pb

trunk sally$ ./pb 1 2 3 4 5 6
0 percent chance of winning

trunk sally$ ./pb 1 2 3e 4 5 6
Invalid arguments

And she commits her changes, easy as falling off a greasy log.

trunk sally$ svn commit -m "use strtol. atoi is deprecated."
Sending        trunk/pb.c
Transmitting file data .
Committed revision 12.

After this commit is finished, Subversion removes her lock so that others can once again modify the file.