Which head must be positioned before merging?

Is there a premise when you want to merge?

I mean the following: I have, say, the old rev 1000. Meanwhile, I made 234 commits, and I'm on rev 1234. Now I need to go back to rev 1000 to implement the fix for the client. I commit the fix, provide the release to the client, and get commit 1235.

This is just a small change: it affects only one file.

At this moment I have two heads: 1235 (whose parent is 1000) and 1234. Their total (grand-grand -...- parent) is 1000.

If I give out hg merge, which follows hg status, I get a giant list of changes.

However, if I was doing at first hg update -C 1234, and then hg merge, and hg statusthen I can only see their own unique variation (if I'm not mistaken that just happened).

Basically, doing this:

hg update -C 1234
hg merge  # (merging 1234 and 1235, my two only heads)
hg status

gives a different status:

hg update -C 1235
hg merge  # (merging 1234 and 1235, my two only heads)
hg status

So basically, I ask for status ( hg status) after the merger of two identical heads, but the conclusion hg statusseems to depend on what I'm in now.

Is this normal behavior and, if so, is there one head to “prefer” over another?

How do both operations lead to the same state of the repository / source code at the end?

+5
source share
1 answer

Yes, they both lead to the same final state. Mergers are almost 100% symmetrical in Mercurial. The only asymmetric part is called branches:

hg update branch-a
hg merge branch-b
hg commit

branch-a. branch-b branch-b. , hg branch , , .

1234, . , , , - .

, , . () . , , :

  • bugfix? , .

  • ? , bugfix .

- , bugfix , .

, , -

hg update 1.x
# fix bug
hg commit
hg tag 1.3

1.x , 1.3 bugfix. , default. , :

hg update default
hg merge 1.x
hg commit

Mercurial.

+5

All Articles