Clone, Add, Status, Commit

By this time Harry is done skiving off and is ready to start coding. First he needs to clone to get his own repository instance.

~ harry$ vv clone http://server.futilisoft.com:8080/repos/lottery lottery
Downloading repository...... Done.                                             
Saving new repository... Done.                                                 
Use 'vv checkout lottery <path>' to get a working copy.

Veracity supports the ability to have more than one working copy per repository instance. It does not store the repository instance in the working copy. Rather, they are stored in an area we call the closet. The location of the closet is configurable. By default it is in
~/.sgcloset (Linux/Mac) or
%LOCALAPPDATA%\.sgcloset (Windows).

Now Harry needs a working copy.

~ harry$ vv checkout lottery ./lottery

~ harry$ cd lottery

Since this is Harry’s first time using Veracity, he first sets up his user account.

lottery harry$ vv user create harry

lottery harry$ vv whoami harry

Harry wonders if Sally has already done anything in the new repository.

lottery harry$ ls -al
total 0
drwxr-xr-x   5 harry  staff  170 May 31 10:17 .
drwxr-xr-x  24 harry  staff  816 May 31 10:17 ..
drwxr-xr-x   7 harry  staff  238 May 31 10:17 .sgdrawer

Apparently not. Nothing here but the .sgdrawer administrative area. Jolly good then. It’s time to start coding. He opens his text editor and creates the starting point for their product.

#include <stdio.h>
#include <stdlib.h>

int calculate_result(int white_balls[5], int power_ball)
{
    return 0;
}

int main(int argc, char** argv)
{
    if (argc != 7)
    {
        fprintf(stderr, "Usage: %s power_ball (5 white balls)\n", argv[0]);
        return -1;
    }

    int power_ball = atoi(argv[1]);

    int white_balls[5];
    for (int i=0; i<5; i++)
    {
        white_balls[i] = atoi(argv[2+i]);
    }

    int result = calculate_result(white_balls, power_ball);

    printf("%d percent chance of winning\n", result);

    return 0;
}

Typical of most initial implementations, this is missing a lot of features. But it’s a good place to begin. Before committing his code, he wants to make sure it compiles and runs.

lottery harry$ gcc -std=c99 lottery.c 

lottery harry$ ls -l
total 32
-rwxr-xr-x  1 harry  staff  8904 May 31 10:17 a.out
-rw-r--r--  1 harry  staff   555 May 31 10:17 lottery.c

lottery harry$ ./a.out
Usage: ./a.out power_ball (5 white balls)

lottery harry$ ./a.out 42 1 2 3 4 5
0 percent chance of winning

Righto. Time to store this file in the repository. First Harry needs to add the file to the pending changeset.

lottery harry$ vv add lottery.c

Harry uses the status operation to make sure the pending changeset looks proper.

lottery harry$ vv status
   Added:  @/lottery.c
   Found:  @/a.out

Veracity is reporting that it found a file it doesn’t know what to do about, that a.out file. No time to spit the bit. That’s a compiled executable, which should not be stored in a version control repository. He can just ignore that. Now it’s time to commit the file.

lottery harry$ vv commit -m "initial implementation"

    revision:  2:8d1b667537d569b307e320004ca7cfb10d8aea64
      branch:  master
         who:  harry
        when:  2011/05/31 10:18:23.640 -0500
     comment:  initial implementation
      parent:  1:b669171b03dfcdb78fb332f3d7b09e62d4f05074