#!/bin/sh

CUR=`pwd`
DIR="$SAGE_ROOT"/data/extcode

#check() {
#   if [ $? -ne 0 ]; then 
#      echo "Something went wrong merging in the extcode repo." 
#      echo "Stopping the build." 
#      echo "Please get your extcode repository in good shape and checked in,"
#      echo "then retry the upgrade/package install."
#   fi
#}


if [ ! -d "$DIR" ]; then
   # Brand new install.
   mkdir "$DIR"
   cp -r * .hg* "$DIR"/
else
   # Doing an upgrade, so merge changes.
   cd "$DIR"
   hg ci 
   hg pull "$CUR"
   hg merge tip
   hg ci -m "Check-in during upgrade of Sage."
   hg update
fi

