开发者

Understanding the Mercurial merge changeset

If I have two开发者_高级运维 heads in my repo - C and D which have the common parent of B - and I do an hg merge then a hg commit, what exactly is in that merge changeset? I am trying to understand what I see what I do hg diff -c xyz where xyz is the id of the merged changeset.

Will the changeset show the diffs of all files modified in C and D vs. the state of those files as they existed in the common parent repository B?


A merge commit has two parents, so when running a diff it is important to understand which parent you are diffing against.

hg diff -c <changeset> shows the diff of the changeset relative to the first parent.

From hg help diff:

diff may generate unexpected results for merges, as it will default to comparing against the working directory's first parent changeset if no revisions are specified.

To diff against a specific parent, it is best to provide the explicit revision of both the merge changeset and corrent parent (e.g. hg diff -r <parent> -r <merge changeset>


Mercurial implements a directed acyclic graph so in your merge changeset depends on where you're coming from. When you type "hg merge" it assumes "tip" (much in the same way hg pull assumes the root repository from which you cloned your head) If you type "hg heads" you can see which one is the tip. When you do this merge, assuming C as the tip, you are merging in the changes from D.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜