Search code examples
version-controlmercurialclonecvs

Default path to clone from, like CVSROOT?


A friend asked if it is possible to set the default place where users checkout Mercurial modules from? CVS has a the environment variable CVSROOT, which is used by default.


Solution

  • There is nothing that directly matches the CVSROOT variable in Mercurial, so you won't find a HGROOT environment variable in hg help env.

    But you can do something similar with the schemes extension. It lets you define new URL schemes that act as shortcuts for longer URLs. So if you often type:

    $ hg clone https://bitbucket.org/<something>
    

    then you can load the extension and instead type

    $ hg clone bb://<something>
    

    The bb:// scheme is a default scheme in the extension. These schemes work whereever you can give Mercurial a URL, so you can push/pull with them too.

    You can add your own schemes with something like

    [schemes]
    x = /mnt/server/var/repos/
    

    and then use hg pull x://foo to pull from your /mnt/server/var/repos/foo repository.

    From a comment of yours, it's not clear if you're really after shorthands when you hg pull. They can be created by adding entries to the [paths] section, see hg help paths. If you add

    [paths]
    foo = somewhere
    

    then you can run hg pull foo to pull from somewhere.