February 10, 2009

Mercurial remote repository names

Filed under: Technical — Tags: , — James Bunton @ 7:39 pm

I just discovered that Mercurial supports named shortcuts for repositories. This is great for when you want to be pushing and pulling from several repository URLs without typing their full locations.

I was aware you could set a default and default-push repository in .hg/hgrc, in fact whenever you clone a repository a default remote path is created for you.

You can actually put arbitrary names in there. For example, I have a repository “chatbots” that I cloned from Katie’s repository: http://katharos.id.au/hg/chatbots". I want to be able to push and pull changes from my repository as well as pull from her’s without typing the full path out at any time.


[paths]
default = ssh://hg@delx.au/chatbots
katie = http://katharos.id.au/hg/chatbots

The above snippet goes in the repositories .hg/hgrc, and I can now run commands like this:

$ hg pull katie
$ hg push

This pulls any new changes in from Katie’s repository and pushes them to the default, mine.

1 comment

Greg Darke says:

Ahh, now it makes sense why it takes an entire section to itself (‘[paths]’).

Thanks for this discovery, it will mean I wont have to rely on my bash history as much anymore.

Comments are closed.