简体   繁体   中英

Mercurial - file history doesn't show the same change on different branches

We have had a production issue where a duplicate change was made on different branches (one of them by accident) and we didn't spot it because the Hg file history didn't show us the change on the second branch.

We have done some analysis and this is fairly easy to replicate (see simple example below). Is this is a feature or a bug?

Steps to replicate:

hg init Test
cd Test
hg branch "branch 1"
echo "file1" > test.txt
hg add
hg commit -m "Added test.txt - branch 1"
hg branch "branch 2"
echo "file2" > test.txt
hg commit -m "Updated test.txt - branch 2"
hg update "branch 1"
hg branch "branch 3"
echo "file2" > test.txt
hg commit -m "Updated test.txt - branch 3"

If we run

> hg log test.txt

Then we only get 2 changes shown in the file history - the change on branch 3 is missing.

changeset:   1:1754be7ba0aa
branch:      branch 2
user:        chrisgill
date:        Tue Jun 06 14:30:13 2017 +0100
summary:     Updated test.txt - branch 2

changeset:   0:b10c4fde7ba1
branch:      branch 1
user:        chrisgill
date:        Tue Jun 06 14:30:13 2017 +0100
summary:     Added test.txt - branch 1

But the history for the repository shows all 3 commits

> hg log

changeset:   2:f6f91ab357a6
branch:      branch 3
tag:         tip
parent:      0:b10c4fde7ba1
user:        chrisgill
date:        Tue Jun 06 14:30:14 2017 +0100
summary:     Updated test.txt - branch 3

changeset:   1:1754be7ba0aa
branch:      branch 2
user:        chrisgill
date:        Tue Jun 06 14:30:13 2017 +0100
summary:     Updated test.txt - branch 2

changeset:   0:b10c4fde7ba1
branch:      branch 1
user:        chrisgill
date:        Tue Jun 06 14:30:13 2017 +0100
summary:     Added test.txt - branch 1

That is documented :

Note:

For performance reasons, 'hg log FILE' may omit duplicate changes made on branches and will not show removals or mode changes. To see all such changes, use the --removed switch.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM