Push, Pull, Log, Diff

Sally now needs to clone to get her own repository instance.

~ sally$ 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.

Now Sally needs a working copy.

~ sally$ vv checkout lottery ./lottery

~ sally$ cd lottery

Since this is Sally’s first time using Veracity, she first sets up her user account.

lottery sally$ vv user create sally

lottery sally$ vv whoami sally

OK, let’s take a look at the initial code Harry committed.

lottery sally$ ls -al
total 0
drwxr-xr-x   3 sally  staff  102 May 31 10:18 .
drwxr-xr-x  25 sally  staff  850 May 31 10:18 ..
drwxr-xr-x   7 sally  staff  238 May 31 10:18 .sgdrawer

Hmmm. Harry was supposed to commit the initial code, but there’s nothing here.

But Harry did commit his changes! Why aren’t they here? Ah, he forgot to push. Sally screams so loud at Harry that he can hear her all the way across the Pond.

lottery harry$ vv push
Pushing to http://server.futilisoft.com:8080/repos/lottery:
Pushing... Done.                                                               

Now Sally can pull.

lottery sally$ vv pull
Pulling from http://server.futilisoft.com:8080/repos/lottery:
Pulling... Done.                                                               

After she has pulled, Sally should have the code, right?

lottery sally$ ls -al
total 0
drwxr-xr-x   3 sally  staff  102 May 31 10:18 .
drwxr-xr-x  25 sally  staff  850 May 31 10:18 ..
drwxr-xr-x   7 sally  staff  238 May 31 10:18 .sgdrawer

Hmmm. Still not there. Ah, maybe she needs to vv update the working copy.

lottery sally$ vv update

lottery sally$ ls -al
total 8
drwxr-xr-x   4 sally  staff  136 May 31 10:20 .
drwxr-xr-x  25 sally  staff  850 May 31 10:18 ..
drwxr-xr-x   7 sally  staff  238 May 31 10:20 .sgdrawer
-rw-r--r--   1 sally  staff  555 May 31 10:20 lottery.c

Now that she has the initial code they had previously discussed, Sally is happy as a tick on a fat dog. She wants to check the log to see the details.

lottery sally$ vv log

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

    revision:  1:b669171b03dfcdb78fb332f3d7b09e62d4f05074
         who:  
        when:  2011/05/31 10:16:31.589 -0500

Note the way Veracity describes this commit: 2:8d1b667537d5…. At the lowest level, a Veracity version ID is a cryptographic hash (SHA-1, by default). This is the part after the colon. Before the colon is a friendlier version number, one which starts at zero and increases by one with each new version. This is more intuitive, but these version numbers are valid only in one repository instance.

When Sally decides to take a look at the code, she immediately finds something that makes her nervous as a porcupine in a balloon factory. The program expects the red ball number to be the first argument, followed by the other five. But in the actual lottery, the five white numbers are always drawn and shown first. She worries this will be confusing for users so she decides to fix it. Fortunately it is only necessary to modify a few lines of main().

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

    int power_ball = atoi(argv[6]);

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

Now she uses the status operation to see the pending changes.

lottery sally$ vv status
Modified:  @/lottery.c

No surprise there. Veracity knows that lottery.c has been modified. She wants to double-check by reviewing the actual changes.

lottery sally$ vv diff
=== ================
===   Modified: File @/lottery.c
--- @/lottery.c 76a16c36b9a4cea4a222ff8132f9f242fa04bed1
+++ @/lottery.c 2011/05/31 15:21:39.000 +0000
@@ -11,16 +11,16 @@
 {
     if (argc != 7)
     {
-        fprintf(stderr, "Usage: %s power_ball (5 white balls)\n", argv[0]);
+        fprintf(stderr, "Usage: %s (5 white balls) power_ball\n", argv[0]);
         return -1;
     }
 
-    int power_ball = atoi(argv[1]);
+    int power_ball = atoi(argv[6]);
 
     int white_balls[5];
     for (int i=0; i<5; i++)
     {
-        white_balls[i] = atoi(argv[2+i]);
+        white_balls[i] = atoi(argv[1+i]);
     }
 
     int result = calculate_result(white_balls, power_ball);

Ain’t that the berries!?!

Veracity’s diff command can be configured to integrate with any file comparison tool the user prefers. But we also included a special command which gives seamless integration with SourceGear DiffMerge[35], our free application for comparing and merging, supported on Windows, Mac, and Linux.

lottery sally$ vv diffmerge

Figure 10.1. Sally’s Changes

Sally’s Changes