1

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"
Danny Douglass
  • 390
  • 1
  • 11
  • Sorry, I dont't get your question. Who is the owner? Contact him for what reason? What does not work? Why hgtk? – Oben Sonne Mar 01 '11 at 17:54
  • 1
    mercurial doesn't generally let you edit your config files using the command line. see http://twitter.com/#!/mpmselenic/status/8392230762 – Wooble Mar 01 '11 at 18:00
  • Oben - The owner is a field set in the hgrc file "contact=contact name". It's used in our organization to track the owner of the Hg repository. – Danny Douglass Mar 01 '11 at 18:07
  • Ah, okay, the contact field in the hgrc. I was confused about mentioning hgtk in that context and I misinterpreted the `[does not work]` annotation. So, *Wooble* is right. Also, check [this similar question](http://stackoverflow.com/q/4659135/151299). – Oben Sonne Mar 01 '11 at 18:26

1 Answers1

1

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).

Ry4an Brase
  • 78,112
  • 7
  • 148
  • 169
  • It has nothing to do with being afraid of changing a text file. We have a process for automating creation of our repositories, and it would have been nice to script this into the process. Instead, it's a manual step that can be forgotten or done wrong. – Danny Douglass Mar 03 '11 at 12:51
  • If you just created the repo you can be ham-fisted about it as shown in the update. – Ry4an Brase Mar 03 '11 at 15:28