Unexpected result from bzr merge: line missing?
Terry Jones
terry at jon.es
Thu Jul 29 00:24:50 BST 2010
Hi Martin, thanks for the reply.
>>>>> "Martin" == Martin Pool <mbp at canonical.com> writes:
Martin> On 29 July 2010 03:23, Terry Jones <terry at jon.es> wrote:
>
> I have two branches. In the trunk, I have file.py with the following
> (line numbers included for discussion):
>
> 416 about = guessValue(about)
> 417 if about:
> 418 result.about = about.encode('utf-8')
>
> Whereas in the branch, I have:
>
> 407 if about:
> 408 about = guessValue(about)
> 409 if about:
> 410 result.about = about
Martin> So 'about' is originally assigned somewhere much further up in this
Martin> branch?
Yes, that's right.
> If I do a diff of trunk branch, I see:
>
> 416c406
> < about = guessValue(about)
> ---
>>
> 418c408,410
> < result.about = about.encode('utf-8')
> ---
>> about = guessValue(about)
>> if about:
>> result.about = about
>
> Which appears correct. Note that line 416 of the trunk is clearly present
> in the diff.
Martin> I'm not sure what diff you're showing here. Is that the diff from
Martin> file.py.BASE to file.py.THIS (or OTHER)?
That was a diff on the two original source files, one in the trunk and one
in the branch. I.e., it's the same as diff OTHER THIS.
> Now if I cd into the branch and do a bzr merge on the branch, the output
> looks like this:
>
> 408
> 409 if about:
> 410 <<<<<<< TREE
> 411 about = guessValue(about)
> 412 if about:
> 413 result.about = about
> 414 =======
> 415 result.about = about.encode('utf-8')
> 416 >>>>>>> MERGE-SOURCE
>
>
> Which looks wrong, because line 416 from the trunk will not be present if I
> take the changes from MERGE-SOURCE (trunk). I.e., I'd wind up with:
>
> 416
> 417 if about:
> 418 result.about = about.encode('utf-8')
>
> So where did the "about = guessValue(about)" line from the trunk go?
> Experience tells me the fault must be mine, but I don't see how. The diff
> clearly shows the about = guessValue(about) as being present only in the
> trunk at that point in the file, but it looks like bzr merge is not
> interpreting the diff output correctly.
Martin> bzr merge doesn't actually run diff and then apply it; rather it
Martin> does either a 3-way merge or an annotation-based merge of the files
Martin> directly.
OK, thanks for the clarification - I should've known better (getting old).
Martin> I would guess that these conflicts mean that the line 416 was
Martin> present in the base,
Correct.
Martin> unchanged in trunk,
Correct.
Martin> and "deleted" (actually moved) on the other branch.
Martin> If you run 'bzr remerge --show-base file.py' and post the relevant
Martin> excerpt it might help explain that.
It looks like:
if about:
<<<<<<< TREE
about = guessValue(about)
if about:
result.about = about
||||||| BASE-REVISION
result.about = about
=======
result.about = about.encode('utf-8')
>>>>>>> MERGE-SOURCE
Martin> It would be interesting to see the results of 'remerge --weave'
Martin> too.
The weave output is the same as for the regular merge.
Martin> Pending those results, it does seem like bzr is being basically
Martin> reasonable with these conflicts.
I guess there's something I'm not understanding then. My understanding was
that when I looked at any file with conflicts in it, I'd see something
like:
common1
<<<<<<< TREE
text1
=======
text2
>>>>>>> MERGE-SOURCE
common2
and that I could either use common1/text1/common2 to have things as they
were in my current tree, or I could use common1/text2/common2 to have
things as they were in the merge source. I've always resolved conflicts
that way, usually selecting either text1 or text2 and deleting the other,
and of course occasionally doing some work to manually merge things *within
the <<< >>> block*.
But in the current example it's not as simple, because simply removing
text1 does *not* result in me having the code as it was in the merge
source. The "about = guessValue(about)" line (416 in the merge source,
i.e., the trunk) would then be missing.
So in this case, the correct resolution (which is not complicated, it's
simply to have what was in the merge source) requires me to consider code
that falls *outside* the
<<<<<<< TREE
text1
=======
text2
>>>>>>> MERGE-SOURCE
block, which I find a bit disturbing / counter-intuitive. How far back in
the common1 text (or how far forward in the common2 text) am I supposed to
look before I can be confident I've not overlooked something that bzr merge
didn't flag for me?
I hope I'm being clear - apologies if not, and thanks again for the reply.
Terry
More information about the bazaar
mailing list