blame confusion

Marc Strapetz marc.strapetz at syntevo.com
Tue Mar 5 03:17:24 CST 2013


On 01.03.2013 17:31, Kevin Bullock wrote:
> On 28 Feb 2013, at 4:57 AM, Marc Strapetz wrote:
> 
>> When it comes to blaming merge revisions, I do not understand
>> Mercurial's behavior (version 2.4.2).
>>
>> I've created a file with contents:
>>
>> 1
>> 2
>> 3
>>
>> at r0 and immediately forked 'branch'. In 'branch', the file is modified to:
>>
>> 1
>> 2x  (at r1)
>> 3y  (at r7)
>>
>> In 'default', many lines have been added to the beginning of the file,
>> and finally similar lines to "1","2","3" again:
>>
>> 1   (at r5)
>> 2x  (at r6)
>> 3y  (at r6)
>> .
>> .
>> .
>> 1
>> 2
>> 3
>>
>> Finally, 'branch' is merged to 'default' at r8, resulting in:
>>
>> 1
>> 2x
>> 3y
>> .
>> .
>> .
>> 1
>> 2x
>> 3y
>>
>> So, the last lines have been merged properly, as expected. However a "hg
>> blame" gives something like:
>>
>> 0: 1   <-- should be r5
>> 1: 2x  <-- should be r6
>> 7: 3y  <-- should be r6
>> .
>> .
>> .
>> 0: 1
>> 8: 2x  <-- yes, merged at r8, however here I'd expect to see "1"
>> 8: 3y  <-- the same, here I'd expect to see "7"
>>
>> Is this annotation expected? If so, what is the logic behind this
>> annotation? I can supply a test repository for this scenario.
> 
> Although _you_ may see the first three lines here as distinct from
> the identical lines later in the file, Mercurial doesn't. That is, I'm
> guessing what's happening here is that when Mercurial stores the file
> delta for the merge, it's judging the last few lines as added-in-the-merge.

Yes, it's OK that the last few lines are considered as changed by the
merge commit -- this is what actually happened and this is what the log
shows. But why does Mercurial annotate the *first* lines with the merge
source revisions and not the last lines? IIRC, Git somehow uses the
merge base to map between lines in the blame commit and lines in the
merge source(s). Mercurial does not seem to work this way?

-Marc


More information about the Mercurial-devel mailing list