I have used Mercurial myself as a single user to keep track of the changes I make to my own code, and I think I am already familiar with the fundamentals. However, I am now about to start working on a software project with somebody else in my lab and want to make sure I understand how to properly share code with somebody else using Mercurial.
Our situation is the following: We both have our own repository in a shared volume (i.e. different paths) in a Linux cluster, and we both have read and write access to our own and each other's repositories.
We can call these two repositories: Bob's and Alice's repositories for the purpose of the discussion.
My understanding is that there are multiple ways of having Bob and Alice share their code, two of them being the following:
My interpretation from reading the Mercurial documentation and tutorials online is that the first option above is usually preferred over the second one. One question I have is why?
Can the second option above lead to any problems? What would happen if Bob commits into his own repository while Alice also pushes her changes simultaneously into Bob's repository?
Thanks
Force: Push and Pull A force that changes the direction of an object towards you, would be a pull. On the other hand, if it moves away, it is a push.
The results suggest that for our group of healthy recreationally active subjects, the upper body “pushing” musculature is approximately 1.5–2.7 times stronger than the musculature involved for pulling.
So, when there will be less force of friction, it is easier in that case to move the body. Hence, it is easier to pull than to push a body. Note: We should also know that the force of friction increases when the normal reaction of the surface on the object increases.
Pushing loads is preferable to pulling because it involves less work by the muscles of the lower back and generally allows better visibility. If at all possible, attempt to push loads, carts, etc. instead of pulling them. Understand the load you will be handling and recognize your personal limitations.
Either works and in the end it really doesn't matter because pushing/pulling doesn't do the update
or the merge
for the recipient -- it just moves changeset into the underlying repo, not into the working directory.
The first option, pulling, is more commonly done because:
hg summary
(or hg heads
or hg log
) and then they'll have to hg merge
. So as long as the recipient has to take an explicit action (check and merge) to get your changes they may as well just pull and merge instead. It's no more work for them and less for you.As others have pointed out a repository write-look will prevent commiting during incoming push or pull operations.
From what I've read about Hg's file model, it handles concurrent writes elegantly so file corruption is not an issue.
The issue is more about workflow. There is no "simultaneous" because the later write operation will be blocked until the earlier write operation finishes. If Bob's commit is earlier, then Alice's push will (by default) fail because it would create a new head. She would have to force push to create a new head in Bob's repo and then he would have to merge them. Or she can pull Bob's change and merge then push. If Alice's push is earlier, then Bob's commit will go through, creating a branch that he will have to merge. Either way, a merge is gonna have to happen. What I don't like about this approach is that Bob is now going to be surprised by these new changesets in his repo and he'll have to do hg update to bring them into his working copy anyways.
The model we use on our team of 4 is to have a central repo that everyone pulls/pushes from. This is also where our CI server pulls to run automated builds. This has worked pretty smoothly for 11 months now.
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