Search code examples
mercurialtortoisehghgrc

Set Mercurial (Hg) Contact (or owner) via command line


Is there a way to set the owner (contact field) via the hg or hgtk command line options? I can bring up the repository configuration via:

>> hgtk repoconfig

What I want to do is something along the lines of:

[does not work] >> hgtk repoconfig set contact "Name of Contact"

Solution

  • This can only be done by editing ha hgrc file. You can do it globally, for just your user account, or on a per-repo basis depending on which hgrc file you want to edit.

    Here's the primary author of Mercurial's comment on a similar request: http://twitter.com/#!/mpmselenic/status/8392230762

    More seriously the reason being that's there is no provably safe way to have a program read and write a configuration file that's also human readable in a safe way. It really feels like there is but there's always a case that can catch you (duplicate entries? %include rules? illegally formatted to begin with). It's all hassle and no gain.

    Update

    If you know it's a brand new repo you can do that easily from the command line:

    echo -e "[web]\ncontact = $CONTACT" >> $(hg root)/.hg/hgrc
    

    It only starts getting unsafe if the hgrc already had a [web] section (or two, or one and two %include directives that may have them).