Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

With Mercurial: How to record different machines source code changes happened on

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?

like image 217
halloleo Avatar asked Apr 16 '14 08:04

halloleo


2 Answers

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.

like image 68
Vince Avatar answered Nov 15 '22 11:11

Vince


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.

like image 23
Flortify Avatar answered Nov 15 '22 11:11

Flortify