Harry immediately moves on to his next task, which is to restructure
the tree a bit. He doesn’t want the top level of the repository to
get too cluttered so he decides to move their vast number of source code files into a src
subdirectory.
lottery harry$ mkdir src lottery harry$ hg move lottery.c src lottery harry$ hg st A src/lottery.c R lottery.c ? a.out lottery harry$ hg commit -m "dir structure" lottery harry$ 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
Sally decides having the number 7 as a constant in the
code is ugly enough to scare a bulldog off a meat truck. She adds a #define
to give it a more meaningful
name.
lottery sally$ hg diff diff -r 4031ca2d74bf lottery.c --- a/lottery.c Tue May 17 11:01:04 2011 -0500 +++ b/lottery.c Tue May 17 11:30:14 2011 -0500 @@ -2,6 +2,8 @@ #include <stdio.h> #include <stdlib.h> +#define LUCKY_NUMBER 7 + int calculate_result(int white_balls[5], int power_ball) { for (int i=0; i<5; i++) @@ -50,7 +52,7 @@ return -1; } - if (7 == power_ball) + if (LUCKY_NUMBER == power_ball) { result = result * 2; }
And immediately commits and pushes the change.
lottery sally$ hg commit -m "use a #define for the lucky number" lottery sally$ hg push pushing to http://server.futilisoft.com:8000/ searching for changes abort: push creates new remote heads on branch 'default'! (you should pull and merge or use push -f to force)
Hmmm. Sally needs to pull and merge before she can push her changes.
lottery sally$ hg pull pulling from http://server.futilisoft.com:8000/ searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files (+1 heads) (run 'hg heads' to see heads, 'hg merge' to merge)
She uses hg heads to see about the merge that needs to be done.
lottery sally$ hg heads changeset: 8:b9ea7a983ae6 tag: tip parent: 6:4031ca2d74bf user: Harry <harry@futilisoft.com> date: Tue May 17 11:24:58 2011 -0500 summary: dir structure changeset: 7:7492d7fa4427 user: Sally <sally@futilisoft.com> date: Tue May 17 11:31:26 2011 -0500 summary: use a #define for the lucky number
The hg merge command performs the merge work and leaves the result in her working copy, waiting to be committed.
lottery sally$ hg merge merging lottery.c and src/lottery.c to src/lottery.c 0 files updated, 1 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) lottery sally$ hg st M src/lottery.c R lottery.c ? a.out
And she commits the merge and pushes it up to the server.
lottery sally$ hg commit -m "merge" 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 2 changesets with 2 changes to 2 files