[darcs-users] Best way to create a remote repo

Alexander Staubo alex at byzantine.no
Mon Nov 29 22:58:06 UTC 2004


Pedro Melo Cunha wrote:
> I'm working in a copy of my local repository, and I would like to push 
> my repo to a remote server. It seems really easy to do a darcs push from 
> the local repo, but that assumes that I already have a repo in the 
> remote server.
> 
> What's the recommended way to create a remote repository, that will be 
> used by others?

The shortest route, in my experience:

$ ssh bob at remotebox "mkdir foo && cd foo && darcs init"
$ darcs push bob at remotebox:foo

I've always found the lack of a --repodir=... option for "darcs init" 
annoying, since the "mkdir, cd, darcs init" triple seems like such a 
common use case.

As a workaround I've written a small script, "darcs-init", to help me 
out. You might find it useful.

#!/bin/sh

if [ "$#" == "0" ]
then
   echo "Usage: $0 PATH..."
   echo ""
   echo "where PATH is either a local path or an SSH [user@]host:path."
   exit 2
fi

ssh="$DARCS_SSH"
if [ "$ssh" == "" ]
then
   ssh="ssh"
fi
for repo in "$@"
do
   host=`echo $repo | grep ":" | sed -e "s/^\(.\+\):.\+/\1/"`
   if [ "$host" != "" ]
   then
     path=`echo $repo | sed -e "s/^.\+:\(.*\)/\1/"`
   else
     path="$repo"
   fi
   if [ "$path" == "" ]
   then
     echo "Path missing from repository argument: $repo" >&2
     exit 1
   fi
   if [ "$host" != "" ]
   then
     shell="$ssh $host"
   else
     shell="sh -c"
   fi
   $shell "mkdir -p '$path' && cd '$path' && darcs init"
done

Alexander.




More information about the darcs-users mailing list