pure python 3-way merge

John A Meinel john at arbash-meinel.com
Tue Jul 5 17:48:20 BST 2005


Martin Pool wrote:

>My bzr tree now has some code in bzrlib.merge3 to do a 3-way text
>merge in pure Python.  I think(?) this might remove the main external
>dependency, aside from patch for importing changesets, which I hope we
>can also fix.  I think it works.  Comments or bug reports are welcome.
>
>
>
BUG!! In python2.3 merge3.py currently does not write out lines if MINE
has a tail.

Here is an example:

cat >BASE <<EOF
This
is
the
base
EOF

cp BASE MINE
cp BASE OTHER
echo -e "Some\nmore\nlines" >> MINE

$ diff3 -m MINE BASE OTHER
This
is
the
base
Some
more
lines

$ python2.3 merge3.py MINE BASE OTHER
u | This
u | is
u | the
u | base


I went ahead and created a patch, which tests for proper 'append'
functionality, and it turns out that Merge3.merge_lines() does the right
thing. It seems to be a problem with Merge3.merge_annotated()

The tests pass with python2.4, and they don't run with python2.3 (for
some reason the test stuff doesn't seem to run all of the tests with
python2.3)

If you run my test using python2.4 you get:
$ python2.4 ~/dev/bzr/bzr.dev/bzrlib/merge3.py MINE BASE OTHER
u | This
u | is
u | the
u | base
a | Some
a | more
a | lines

So whose fault is this? It seems we have found a bug in the python2.3
difflib's SequenceMatcher.

John
=:->

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 253 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050705/e444b9e3/attachment.pgp 


More information about the bazaar mailing list