I use Mercurial on 2 different computers changing the same repository. If I want to keep tabs on which changes have happened on which machine, how should I record this?
I came up with the idea of using different user names on the two machines ([ui] -->
username
variable in the hg config file), but does a more appropriate mechanism/variable exists for this?
This looks like a good idea; user names are exactly to identify the committer, here the computer. The alternative would be to work on different branches on each computer and merge in default often. However, the latter is more error-prone.
For a couple of years, you've been able to expand shell variables inside .hg/hgrc
files.
So I just do something like this in my .bash_profile
:
export HGUSER=$(hostname)
Then inside .hg/hgrc
:
username=${HGUSER}
The BIG ADVANTAGE of this technique is that now you can put the EXACT SAME .hg/hgrc
on ALL the machines. The same is true of .bash_profile
: it can be the same on all machines. This helps a lot when you're automating machine configurations!
Note: the HGUSER
environment variable is an old way of telling Mercurial your username, so, technically, setting HGUSER
in .bash_profile
ought to solve the problem on its own, but I believe its use is deprecated/discouraged, and I recommend defining username
in .hg/hgrc
explicitly, as I've shown above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With