What do we do when two users need to work on the same
hg repository?
Problem
By “same”, I mean the same folder in the filesystem. In the case that I encountered, I need to modify the repository on another user’s account, directly, and do the regular commits, pulls, and pushes as if I were working on my own repository.
Discussion
Usually this scenario should not happen. Whenever there are two users, each user usually has his/her own repository. Modifications contributed by the two users are merged using standard version control methods. Furthermore, the ecosystem that the repository relies on should be in a shared state, e.g. in the /opt
folder, so that the users only need to take care of the repository itself.
Now, what happened is that, only the first user will be the main contributor to the repository. Moreover, the repository relies on a heavy ecosystem, which is cumbersome to setup in a new account. Yes, historically, the ecosystem is setup under the second user’s account, and not shared by the first user.
Workaround
One can always do something like following to enforce the manipulation of the repository,
To avoid invoking the super user privilege, add writing permissions to the files in the .hg
folder of the repository.
When the user commits any changes to the repository, the writing permission is required to modify the .hg files.
Then add following information to the hgrc
file in the repository
Then when doing push
and pull
, make sure to interact with the dev
repository defined in the hgrc
file.
In this manner, the commits are directed to the dev
path under the specified user.
Finally, in .hgrc
file, add
to avoid some annoying outputs from the commandline.