Next Jim decides to add some files to the project. He writes up a file containing the prototypes for the JuiceBot 7:
$ mkdir include $ cat >include/jb.h /* Standard JuiceBot hw interface */ #define FLOW_JUICE 0x1 #define POLL_JUICE 0x2 int spoutctl(int port, int cmd, void *x); /* JuiceBot 7 API */ #define APPLE_SPOUT 0x7e #define BANANA_SPOUT 0x7f void dispense_apple_juice (); void dispense_banana_juice (); ^D
Then adds a couple skeleton source files which he wants Abe and Beth to fill in:
$ mkdir src $ cat >src/apple.c #include "jb.h" void dispense_apple_juice() { /* Fill this in please, Abe. */ } ^D $ cat >src/banana.c #include "jb.h" void dispense_banana_juice() { /* Fill this in please, Beth. */ } ^D
Now Jim tells monotone to add these files to its record of his working copy. He specifies one filename and one directory; monotone recursively scans the directory and adds all its files.
$ monotone --db=~/jim.db add include/jb.h src monotone: adding include/jb.h to working copy add set monotone: adding src/apple.c to working copy add set monotone: adding src/banana.c to working copy add set
This command produces a record of Jim's intentions in a special file called MT/work, stored in the working copy. The file is plain text:
$ cat MT/work add_file "include/jb.h" add_file "src/apple.c" add_file "src/banana.c"
Jim then gets up from his machine to get a coffee. When he returns he has forgotten what he was doing. He asks monotone:
$ monotone --db=jim.db status new_manifest [2098eddbe833046174de28172a813150a6cbda7b] old_revision [] old_manifest [] add_file "include/jb.h" add_file "src/apple.c" add_file "src/banana.c" patch "include/jb.h" from [] to [3b12b2d0b31439bd50976633db1895cff8b19da0] patch "src/apple.c" from [] to [2650ffc660dd00a08b659b883b65a060cac7e560] patch "src/banana.c" from [] to [e8f147e5b4d5667f3228b7bba1c5c1e639f5db9f]
The output of this command tells Jim that his edits, so far, constitute only the addition of some files. In the output we can see one pecularity of monotone's changeset format. The pecularity is that when monotone records a “new file”, it actually records two separate events: the addition of an empty file to the working copy, and a patch of that file from empty to its intended contents.
Jim wants to see the actual details of the files he added, however, so he runs a command which prints out the status and a GNU “unified diff” of the patches involved in the changeset:
$ monotone --db=jim.db diff # # add_file "include/jb.h" # # add_file "src/apple.c" # # add_file "src/banana.c" # # patch "include/jb.h" # from [] # to [3b12b2d0b31439bd50976633db1895cff8b19da0] # # patch "src/apple.c" # from [] # to [2650ffc660dd00a08b659b883b65a060cac7e560] # # patch "src/banana.c" # from [] # to [e8f147e5b4d5667f3228b7bba1c5c1e639f5db9f] # --- include/jb.h +++ include/jb.h @ -0,0 +1,13 @ +/* Standard JuiceBot hw interface */ + +#define FLOW_JUICE 0x1 +#define POLL_JUICE 0x2 +#define SET_INTR 0x3 +int spoutctl(int port, int cmd, void *x); + +/* JuiceBot 7 API */ + +#define APPLE_SPOUT 0x7e +#define BANANA_SPOUT 0x7f +void dispense_apple_juice (); +void dispense_banana_juice (); --- src/apple.c +++ src/apple.c @ -0,0 +1,7 @ +#include "jb.h" + +void +dispense_apple_juice() +{ + /* Fill this in please, Abe. */ +} --- src/banana.c +++ src/banana.c @ -0,0 +1,7 @ +#include "jb.h" + +void +dispense_banana_juice() +{ + /* Fill this in please, Beth. */ +}