Question

I've recently had a problem tracking down a changeset responsible for a specific line in the source file. hg blame was giving me a revision that has never been merged into the branch I was interested in.

I discovered that if there's a similar unrelated change made earlier, Mercurial would still show it as originating revision. Is this a bug or it's supposed to behave like this? If latter, could you explain why.

Here's the minimum example:

hg init test
cd test

# Create a new file that has 3 lines
echo "111\n222\n333" > test.txt
hg commit -Am "Original file"

# Append "444" to the file
echo "444" >> test.txt
hg commit -m "Abandoned change"

# Go back to the first revision and append the same "444" to the file
hg up 0
echo "444" >> test.txt
hg commit -m "Actual change"

Here's what the repo looks like:

$ hg glog
@  changeset:   2:1b16b07e058e
|  tag:         tip
|  parent:      0:e58635de081c
|  user:        Nobody <nobody@nowhere.org>
|  date:        Tue Nov 20 17:17:41 2012 +0100
|  summary:     Actual change
|
| o  changeset:   1:b02ee64b2e2d
|/   user:        Nobody <nobody@nowhere.org>
|    date:        Tue Nov 20 17:17:41 2012 +0100
|    summary:     Abandoned change
|
o  changeset:   0:e58635de081c
   user:        Nobody <nobody@nowhere.org>
   date:        Tue Nov 20 17:17:41 2012 +0100
   summary:     Original file

Now when I run hg blame I expect to see the last line coming from the changeset 2, not changeset 1.

$ hg blame test.txt
0: 111
0: 222
0: 333
1: 444
Était-ce utile?

La solution

This is not the intended behavior, you hit Bug 1839.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top