[PATCH] Python-native patching for changeset application

Aaron Bentley aaron.bentley at utoronto.ca
Wed Jul 27 20:10:24 BST 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,
I've implemented native Python patching for bzr changesets.  This
furthers the goals of reducing external dependencies and making bzr easy
to install.

It only does exact patching, and I think that's a good thing; we don't
need or want fuzzy patching when applying changesets-- if there's a
difference between the expected text and what's actually there, that
indicates a bug.

Once the patch is parsed, exact patching turns out to be stupid-simple.
  I should have written it ages ago.  I think it would be useful to get
this functionality into core Python.  Any idea how to go about that?

In the process, I've introduced IterableFile, which is a wrapper to
convert any iterator of strings into a file-like object.  I thought it
was best to do it once and sweat the details rather than quickly
reinventing it whenever I have an iterator but want a file.

Using IterableFile instead of StringIO means that we can patch files of
arbitrary size without much memory overhead.

Note that the tests introduced by native-patching require internal_diff
to behave properly, i.e. with my newline-fix patch.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFC59wg0F+nu1YWqI0RAmEDAJ9rZ8XYP7Flp9BUf9vJimfkOnAQsACeJlml
2gVPClJHHQVMsu17MpD09l0=
=sJj+
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: add-iterable.patch
Type: text/x-patch
Size: 8610 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050727/2917464c/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: add-patches.patch
Type: text/x-patch
Size: 268426 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050727/2917464c/attachment-0001.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: native-patching.patch
Type: text/x-patch
Size: 3818 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050727/2917464c/attachment-0002.bin 


More information about the bazaar mailing list