Is there a command to set the default path in mercurial?

No, there's no builtin command; you need to add it in .hg/hgrc yourself.


There isn't a command for this and there won't be one. One of the times this was suggested the primary author of Mercurial, Matt, tweeted:

What is it with coders who are intimidated by text-based config files? Like doctors that can't stand blood.

You can make the hg erc command open up that editor by putting this in your personal .hgrc:

[alias]
erc = !$EDITOR `$HG root`/.hg/hgrc

(that last from Steve Losh)

If you want to get fancy you could do a post-clone hook that modifies the .hg\hgrc file using sed or similar, but you'll not find that functionality in Mercurial any time soon.


If you're running TortoiseHg, you can also bring up the Repository Explorer and select Synchronize->Configure Paths... this will allow you to define the default path, and any additional paths you may want. For example, you could configure a path with the alias 'bitbucket' and use your default path for a local clone, server copy, etc...

Changes made in this fashion are not stored in the .hgrc or Mercurial.ini file because they are per repo - they are instead stored in the .hg directory.