Unexpected result from bzr merge: line missing?

Martin Pool mbp at canonical.com
Wed Jul 28 23:50:25 BST 2010


On 29 July 2010 03:23, Terry Jones <terry at jon.es> wrote:
> I've just run into something odd using bzr merge, and after asking a few
> people to look at it have decided to post a summary here to see if anyone
> can point out what I'm doing wrong. I'm running Hardy with:
>
> $ bzr --version
> Bazaar (bzr) 2.1.2
>  Python interpreter: /usr/bin/python 2.5.2
>  Python standard library: /usr/lib/python2.5
>  Platform: Linux-2.6.24-28-generic-x86_64-with-debian-lenny-sid
>  bzrlib: /usr/lib/python2.5/site-packages/bzrlib
>
>
> 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

So 'about' is originally assigned somewhere much further up in this branch?

>
> 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.

I'm not sure what diff you're showing here.  Is that the diff from
file.py.BASE to file.py.THIS (or OTHER)?

>
> 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.

bzr merge doesn't actually run diff and then apply it; rather it does
either a 3-way merge or an annotation-based merge of the files
directly.

I would guess that these conflicts mean that the line 416 was present
in the base, unchanged in trunk, and "deleted" (actually moved) on the
other branch.  If you run 'bzr remerge --show-base file.py' and post
the relevant excerpt it might help explain that.  It would be
interesting to see the results of 'remerge --weave' too.

Pending those results, it does seem like bzr is being basically
reasonable with these conflicts.
-- 
Martin



More information about the bazaar mailing list