In the Subversion example, this is the place where Sally asks for a lock. But Mercurial doesn’t support lock. |
Harry updates his repository instance.
lottery harry$ hg pull pulling from http://server.futilisoft.com:8000/ searching for changes adding changesets adding manifests adding file changes added 1 changesets with 0 changes to 0 files (run 'hg update' to get a working copy) lottery harry$ hg update 0 files updated, 0 files merged, 387 files removed, 0 files unresolved lottery harry$ ls -l total 8 -rw-r--r-- 1 harry staff 66 May 17 11:47 Makefile drwxr-xr-x 3 harry staff 102 May 17 13:58 src
Sod it! That Sally must have her landlady face on. She’s deleted all his email code!
Harry decides to indent[24] pb.c
.
lottery harry$ indent src/pb.c lottery harry$ hg st M src/pb.c ? pb.c.BAK
This is getting shambolic. Harry calms down and reverts the changes.
lottery harry$ hg revert src/pb.c lottery harry$ hg st ? pb.c.BAK ? src/pb.c.orig lottery harry$ rm pb.c.BAK src/pb.c.orig
Sally has
decided to eliminate uses of atoi()
, which is deprecated.
lottery sally$ hg diff diff -r a3a4497e7ff6 src/pb.c --- a/src/pb.c Tue May 17 14:04:44 2011 -0500 +++ b/src/pb.c Tue May 17 14:10:51 2011 -0500 @@ -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); lottery sally$ make gcc -std=c99 -Wall -Wextra -Werror pb.c -o pb lottery sally$ ./pb 1 2 3 4 5 6 0 percent chance of winning lottery sally$ ./pb 1 2 3e 4 5 6 Invalid arguments
And she commits her changes, easy as dialing BR-549.
lottery sally$ hg commit -m "use strtol. atoi is deprecated." lottery sally$ hg push pushing to http://server.futilisoft.com:8000/ searching for changes remote: adding changesets remote: adding manifests remote: adding file changes remote: added 1 changesets with 1 changes to 1 files