Shell function for cloning Mercurial repositories

One of the things that I find myself needing to do often is clone a repository from our mercurial server. All of our repositories are under a directory on the server that is accessibel through ssh, so I wanted to be able to type in a command on the command line with the name of the remote reposirotry and, optionally, the name of the local clone. If I leave out the second argument, it creates a local clone with the same name.

So I wrote a small function that I put in my .profile (you can add it to your .bash_rc, .bash_profile or whatever gets loaded when you start a new terminal session) The function loooks like this:

function hgclone() { hg clone ssh://user@mercurial.server.com/repos/$1 $2; }

This allows me to type in the command:

$ hgclone repository [localclone]

rather than having to remeber and type in the full path to the remote repository.

If you are registered you need to log in to comment, if not, please sign up.