Mercurial: Did not pull before committing local changes and push. Created 8+ heads
I read all the questions suggested while posing, but I just ended up getting confused :S I made a few changes and committed and pushed them. But later I came to know that the repository was pushed to, before I pushed to it. So My questions are:
Q1. Did my pushing overwrite the repository, i.e does the repository no longer have the changes that were pushed before me?
Q2. What should I do in such cases? I need to have the changes that I made, and the other changes too, w/o having to make the other guy pull my code, re-commit, re-push, and I pulling again, just to get the same working copy.
Q3. Is there anyway that the code can be updated/pulled implicitly before I commit/push?
Q4. What is the rebase option? I read about it on the Documentation, but the changes I perform on the code are not private.
Assumptions:
- There aren't any branches crea开发者_运维技巧ted. (Well, they are created, but they are different modules, and I am not concerned with them).
- I use Eclipse and MercurialEclipse.
EDIT: Sorry if the question is a (possible) duplicate of existing question.
You can't destroy remote changes by pushing. You can create multiple heads with -f
, but you can't create destroy history just by pushing.
To get a good look at the state of the repository to see what's happened, use hg serve
and look at it in the browser (probably http://localhost:8000/graph). Then you can see visually what the state of heads and merges is.
When I manage to create a medusa-repo in hg, I determine which branch is going to be "mainline". Then I go to each sub-branch and perform this process:
hg up -r subbranch
hg merge -r mainline-branch
hg commit -m "merged from main"
hg up -r mainline-branch
hg merge -r subranch
hg commit -m "brought in the subchanges from subbranch"
By merging to the subbranch first, I make sure that the mainline doesn't get damaged, then I can trivially merge to mainline.
This is not a major crisis; this just requires working with the other developers so you all start hitting the same branch again in the next day or so.
As far as I understand Mercurial, by default, it's not possible to push when that push would create a new remote head.
In other words: if someone else pushed before you, and you didn't pulled in and merged those changes.
This behaviour can be changed however using
push -f
Did you use that option?
Mr. Spolsky explains it way better in his tutorial.
Q3. Is there anyway that the code can be updated/pulled implicitly before I commit/push?
In the .hg/hgrc, add
[hooks]
pre-commit = hg pull -u
精彩评论