Sally realizes that C99 has a bool
type that should have been used.
lottery sally$ hg diff diff -r 76fcfc4170dc src/pb.c --- a/src/pb.c Tue May 17 14:44:56 2011 -0500 +++ b/src/pb.c Tue May 17 14:51:23 2011 -0500 @@ -2,6 +2,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <stdbool.h> #define LUCKY_NUMBER 7 #define MAX_WHITE_BALL 59 @@ -35,7 +36,7 @@ { int balls[6]; int count_balls = 0; - int favorite = 0; // this should be a bool + bool favorite = false; for (int i=1; i<argc; i++) { @@ -45,7 +46,7 @@ { if (0 == strcmp(arg, "-favorite")) { - favorite = 1; + favorite = true; } else {
And she commits the change to her private branch.
lottery sally$ hg commit -m "use the bool type" 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 (+1 heads)
Meanwhile, Harry has been grumbling about Sally’s butchering of the Queen’s English and decides to correct the spelling of the word “favourite”.
lottery harry$ hg diff diff -r e92fd20d2bc8 src/pb.c --- a/src/pb.c Tue May 17 14:49:12 2011 -0500 +++ b/src/pb.c Tue May 17 14:53:11 2011 -0500 @@ -57,7 +57,7 @@ { int balls[6]; int count_balls = 0; - int favorite = 0; // this should be a bool + int favourite = 0; // this should be a bool for (int i=1; i<argc; i++) { @@ -65,9 +65,9 @@ if ('-' == arg[0]) { - if (0 == strcmp(arg, "-favorite")) + if (0 == strcmp(arg, "-favourite")) { - favorite = 1; + favourite = 1; } else { @@ -108,7 +108,7 @@ result = result * 2; } - if (favorite) + if (favourite) { result = result * 2; } @@ -118,7 +118,7 @@ return 0; usage_error: - fprintf(stderr, "Usage: %s [-favorite] (5 white balls) power_ball\n", argv[0]); + fprintf(stderr, "Usage: %s [-favourite] (5 white balls) power_ball\n", argv[0]); return -1; }
Feeling quite chuffed about his pedantry, Harry proceeds to commit the change.
lottery harry$ hg commit -m "fixed spelling error"
And to once again merge Sally’s changes into the default branch.
lottery harry$ hg merge -r 4f188690b962 merging src/pb.c warning: conflicts during merge. merging src/pb.c failed! 0 files updated, 0 files merged, 0 files removed, 1 files unresolved use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
Crikey! Conflicts in pb.c
again.
lottery harry$ hg diff diff -r a0c6fdbdd95f src/pb.c --- a/src/pb.c Tue May 17 14:53:41 2011 -0500 +++ b/src/pb.c Tue May 17 14:55:08 2011 -0500 @@ -2,6 +2,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <stdbool.h> #define LUCKY_NUMBER 7 #define MAX_WHITE_BALL 59 @@ -57,7 +58,11 @@ { int balls[6]; int count_balls = 0; +<<<<<<< .working int favourite = 0; // this should be a bool +======= + bool favorite = false; +>>>>>>> .merge-right.r22 for (int i=1; i<argc; i++) { @@ -67,7 +72,11 @@ { if (0 == strcmp(arg, "-favourite")) { +<<<<<<< .working favourite = 1; +======= + favorite = true; +>>>>>>> .merge-right.r22 } else {
That is a spot of bother. Harry quickly realises this conflict
needs to be resolved manually by keeping the proper spelling
but converting the type to bool
like Sally did.
lottery harry$ hg diff diff -r a0c6fdbdd95f src/pb.c --- a/src/pb.c Tue May 17 14:53:41 2011 -0500 +++ b/src/pb.c Tue May 17 14:56:41 2011 -0500 @@ -2,6 +2,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <stdbool.h> #define LUCKY_NUMBER 7 #define MAX_WHITE_BALL 59 @@ -57,7 +58,7 @@ { int balls[6]; int count_balls = 0; - int favourite = 0; // this should be a bool + bool favourite = false; for (int i=1; i<argc; i++) { @@ -67,7 +68,7 @@ { if (0 == strcmp(arg, "-favourite")) { - favourite = 1; + favourite = true; } else {
After manually merging the changes, Harry proceeds to resolve the conflict and commit the merge.
lottery harry$ hg resolve -m src/pb.c lottery harry$ hg commit -m "merge, conflicts fixed" lottery harry$ hg push ...
And all of Futilisoft’s customers lived happily ever after.