#!/bin/bash

NEW_FILE="$1"
OLD_FILE="$2"

SHELF_NAME="compare-times-shelf"

trap "hg import --no-commit $SHELF_NAME" SIGINT SIGTERM

# make the old version
#hg shelve --all --name $SHELF_NAME
hg diff > $SHELF_NAME && hg revert -a
make clean
make timed 2>&1 | tee "$OLD_FILE"


# make the current version
if [ -z "$(cat $SHELF_NAME)" ]; then
    # there is no diff, so just copy the time file
    cp "$OLD_FILE" "$NEW_FILE"
else
    hg import --no-commit $SHELF_NAME && mv $SHELF_NAME "$SHELF_NAME-$(date | base64).bak"
    make clean
    make timed 2>&1 | tee "$NEW_FILE"
fi

#!/bin/bash

NEW_FILE="$1"
OLD_FILE="$2"

SHELF_NAME="compare-times-shelf"

trap "hg import --no-commit $SHELF_NAME" SIGINT SIGTERM

# make the old version
#hg shelve --all --name $SHELF_NAME
hg diff > $SHELF_NAME && hg revert -a
make clean
make timed 2>&1 | tee "$OLD_FILE"


# make the current version
hg import --no-commit $SHELF_NAME && mv $SHELF_NAME "$SHELF_NAME-$(date | base64).bak"
make clean
make timed 2>&1 | tee "$NEW_FILE"

--- 
+++ 
@@ -15,6 +15,11 @@
 
 
 # make the current version
-hg import --no-commit $SHELF_NAME && mv $SHELF_NAME "$SHELF_NAME-$(date | base64).bak"
-make clean
-make timed 2>&1 | tee "$NEW_FILE"
+if [ -z "$(cat $SHELF_NAME)" ]; then
+    # there is no diff, so just copy the time file
+    cp "$OLD_FILE" "$NEW_FILE"
+else
+    hg import --no-commit $SHELF_NAME && mv $SHELF_NAME "$SHELF_NAME-$(date | base64).bak"
+    make clean
+    make timed 2>&1 | tee "$NEW_FILE"
+fi
Update the timing file so that if there is no diff, we don't double compile
