[bundle] make bzr work with diffutils >= 2.8.4

Marien Zwart marienz at gentoo.org
Fri Aug 25 21:46:23 BST 2006


From diffutils NEWS:

'''Diff now simply prints "Files A and B differ" instead of "Binary
files A and B differ".'''

bzr checks for "binary files" in the output in diff.py and
test_diff.py. If the "binary" bit is made optional it passes its tests
with current diffutils. According to John A. Meinel in launchpad bug
57614 this code is triggered when binary conflicts are encountered.

Attached are two bundles, one for 0.9 and one for bzr.dev, that fix
this.

-- 
Marien.
-------------- next part --------------
# Bazaar revision bundle v0.8
#
# message:
#   merge.
# committer: Marien Zwart <marienz at gentoo.org>
# date: Fri 2006-08-25 22:43:30.525000095 +0200

=== modified file bzrlib/diff.py
--- bzrlib/diff.py
+++ bzrlib/diff.py
@@ -192,7 +192,7 @@
             # 'diff' gives retcode == 2 for all sorts of errors
             # one of those is 'Binary files differ'.
             # Bad options could also be the problem.
-            # 'Binary files' is not a real error, so we suppress that error
+            # 'Binary files' is not a real error, so we suppress that error.
             lang_c_out = out
 
             # Since we got here, we want to make sure to give an i18n error
@@ -207,7 +207,8 @@
                                ' natively: %r' % (diffcmd,))
 
             first_line = lang_c_out.split('\n', 1)[0]
-            m = re.match('^binary files.*differ$', first_line, re.I)
+            # Starting with diffutils 2.8.4 the word "binary" was dropped.
+            m = re.match('^(binary )?files.*differ$', first_line, re.I)
             if m is None:
                 raise BzrError('external diff failed with exit code 2;'
                                ' command: %r' % (diffcmd,))

=== modified file bzrlib/tests/test_diff.py
--- bzrlib/tests/test_diff.py
+++ bzrlib/tests/test_diff.py
@@ -115,7 +115,11 @@
         try:
             os.environ['LANG'] = 'C'
             lines = external_udiff_lines(['\x00foobar\n'], ['foo\x00bar\n'])
-            self.assertEqual(['Binary files old and new differ\n', '\n'], lines)
+            # Older versions of diffutils say "Binary files", newer
+            # versions just say "Files".
+            self.assertContainsRe(lines[0],
+                                  '(Binary f|F)iles old and new differ\n')
+            self.assertEquals(lines[1:], ['\n'])
         finally:
             if orig_lang is None:
                 del os.environ['LANG']

# revision id: marienz at gentoo.org-20060825204330-912b977a14a5a87f
# sha1: 9af754b94bd68d05530ea359c3b1e0cb45017aea
# inventory sha1: b8175acfbc2284ce2296f1c1037c1c8ca32ebde5
# parent ids:
#   pqm at pqm.ubuntu.com-20060825200624-719b2ca847a04dfa
#   marienz at gentoo.org-20060824180144-b5b013e11e5709f4
# base id: pqm at pqm.ubuntu.com-20060825200624-719b2ca847a04dfa
# properties:
#   branch-nick: bzr.dev

# message:
#   Make the tests pass with recent versions of diffutils.
# committer: Marien Zwart <marienz at gentoo.org>
# date: Thu 2006-08-24 20:01:44.809999943 +0200

=== modified file bzrlib/tests/test_diff.py // encoding:base64
LS0tIGJ6cmxpYi90ZXN0cy90ZXN0X2RpZmYucHkKKysrIGJ6cmxpYi90ZXN0cy90ZXN0X2RpZmYu
cHkKQEAgLTExMSw3ICsxMTEsMTEgQEAKIAogICAgIGRlZiB0ZXN0X2V4dGVybmFsX2RpZmZfYmlu
YXJ5KHNlbGYpOgogICAgICAgICBsaW5lcyA9IGV4dGVybmFsX3VkaWZmX2xpbmVzKFsnXHgwMGZv
b2JhclxuJ10sIFsnZm9vXHgwMGJhclxuJ10pCi0gICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwoWydC
aW5hcnkgZmlsZXMgb2xkIGFuZCBuZXcgZGlmZmVyXG4nLCAnXG4nXSwgbGluZXMpCisgICAgICAg
ICMgT2xkZXIgdmVyc2lvbnMgb2YgZGlmZnV0aWxzIHNheSAiQmluYXJ5IGZpbGVzIiwgbmV3ZXIK
KyAgICAgICAgIyB2ZXJzaW9ucyBqdXN0IHNheSAiZmlsZXMiLgorICAgICAgICBzZWxmLmFzc2Vy
dENvbnRhaW5zUmUobGluZXNbMF0sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAnKEJp
bmFyeSBmfEYpaWxlcyBvbGQgYW5kIG5ldyBkaWZmZXJcbicpCisgICAgICAgIHNlbGYuYXNzZXJ0
RXF1YWxzKGxpbmVzWzE6XSwgWydcbiddKQogCiAgICAgZGVmIHRlc3Rfbm9fZXh0ZXJuYWxfZGlm
ZihzZWxmKToKICAgICAgICAgIiIiQ2hlY2sgdGhhdCBOb0RpZmYgaXMgcmFpc2VkIHdoZW4gZGlm
ZiBpcyBub3QgYXZhaWxhYmxlIiIiCgo=

# revision id: marienz at gentoo.org-20060824180144-b5b013e11e5709f4
# sha1: fd7d1ad679b4fde74c2d5927d4bb67b0e7dc6bac
# inventory sha1: 18333f103b8c13ac42673e56e272805790a275c5
# parent ids:
#   marienz at gentoo.org-20060824174709-83cf7a51d41c69f8
# properties:
#   branch-nick: bzr.0.9

# message:
#   Make external diff in binary mode work with recent versions of diffutils.
# committer: Marien Zwart <marienz at gentoo.org>
# date: Thu 2006-08-24 19:47:09.569000006 +0200

=== modified file bzrlib/diff.py // encoding:base64
LS0tIGJ6cmxpYi9kaWZmLnB5CisrKyBienJsaWIvZGlmZi5weQpAQCAtMTY2LDggKzE2Niw5IEBA
CiAgICAgICAgICAgICAjICdkaWZmJyBnaXZlcyByZXRjb2RlID09IDIgZm9yIGFsbCBzb3J0cyBv
ZiBlcnJvcnMKICAgICAgICAgICAgICMgb25lIG9mIHRob3NlIGlzICdCaW5hcnkgZmlsZXMgZGlm
ZmVyJy4KICAgICAgICAgICAgICMgQmFkIG9wdGlvbnMgY291bGQgYWxzbyBiZSB0aGUgcHJvYmxl
bS4KLSAgICAgICAgICAgICMgJ0JpbmFyeSBmaWxlcycgaXMgbm90IGEgcmVhbCBlcnJvciwgc28g
d2Ugc3VwcHJlc3MgdGhhdCBlcnJvcgotICAgICAgICAgICAgbSA9IHJlLm1hdGNoKCdeYmluYXJ5
IGZpbGVzLipkaWZmZXIkJywgZmlyc3RfbGluZSwgcmUuSSkKKyAgICAgICAgICAgICMgJ0JpbmFy
eSBmaWxlcycgaXMgbm90IGEgcmVhbCBlcnJvciwgc28gd2Ugc3VwcHJlc3MgdGhhdCBlcnJvci4K
KyAgICAgICAgICAgICMgU3RhcnRpbmcgd2l0aCBkaWZmdXRpbHMgMi44LjQgdGhlIHdvcmQgImJp
bmFyeSIgd2FzIGRyb3BwZWQuCisgICAgICAgICAgICBtID0gcmUubWF0Y2goJ14oYmluYXJ5ICk/
ZmlsZXMuKmRpZmZlciQnLCBmaXJzdF9saW5lLCByZS5JKQogICAgICAgICAgICAgaWYgbm90IG06
CiAgICAgICAgICAgICAgICAgcmFpc2UgQnpyRXJyb3IoJ2V4dGVybmFsIGRpZmYgZmFpbGVkIHdp
dGggZXhpdCBjb2RlIDI7JwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICcgY29tbWFu
ZDogJXInICUgKGRpZmZjbWQsKSkKCg==

# revision id: marienz at gentoo.org-20060824174709-83cf7a51d41c69f8
# sha1: a7a4000ddb2b723ba82c62a11104c4ed354abe13
# inventory sha1: 03cc983b5e08ffbcdbb02fba0f4733c973d0a554
# parent ids:
#   pqm at pqm.ubuntu.com-20060811102108-06a24f3a1d4e7d82
# properties:
#   branch-nick: bzr.0.9

-------------- next part --------------
# Bazaar revision bundle v0.8
#
# message:
#   Make the tests pass with recent versions of diffutils.
# committer: Marien Zwart <marienz at gentoo.org>
# date: Thu 2006-08-24 20:01:44.809999943 +0200

=== modified file bzrlib/diff.py // last-changed:marienz at gentoo.org-20060824174
... 709-83cf7a51d41c69f8
--- bzrlib/diff.py
+++ bzrlib/diff.py
@@ -166,8 +166,9 @@
             # 'diff' gives retcode == 2 for all sorts of errors
             # one of those is 'Binary files differ'.
             # Bad options could also be the problem.
-            # 'Binary files' is not a real error, so we suppress that error
-            m = re.match('^binary files.*differ$', first_line, re.I)
+            # 'Binary files' is not a real error, so we suppress that error.
+            # Starting with diffutils 2.8.4 the word "binary" was dropped.
+            m = re.match('^(binary )?files.*differ$', first_line, re.I)
             if not m:
                 raise BzrError('external diff failed with exit code 2;'
                                ' command: %r' % (diffcmd,))

=== modified file bzrlib/tests/test_diff.py
--- bzrlib/tests/test_diff.py
+++ bzrlib/tests/test_diff.py
@@ -111,7 +111,11 @@
 
     def test_external_diff_binary(self):
         lines = external_udiff_lines(['\x00foobar\n'], ['foo\x00bar\n'])
-        self.assertEqual(['Binary files old and new differ\n', '\n'], lines)
+        # Older versions of diffutils say "Binary files", newer
+        # versions just say "files".
+        self.assertContainsRe(lines[0],
+                              '(Binary f|F)iles old and new differ\n')
+        self.assertEquals(lines[1:], ['\n'])
 
     def test_no_external_diff(self):
         """Check that NoDiff is raised when diff is not available"""

# revision id: marienz at gentoo.org-20060824180144-b5b013e11e5709f4
# sha1: fd7d1ad679b4fde74c2d5927d4bb67b0e7dc6bac
# inventory sha1: 18333f103b8c13ac42673e56e272805790a275c5
# parent ids:
#   marienz at gentoo.org-20060824174709-83cf7a51d41c69f8
# base id: pqm at pqm.ubuntu.com-20060811102108-06a24f3a1d4e7d82
# properties:
#   branch-nick: bzr.0.9

# message:
#   Make external diff in binary mode work with recent versions of diffutils.
# committer: Marien Zwart <marienz at gentoo.org>
# date: Thu 2006-08-24 19:47:09.569000006 +0200

=== modified file bzrlib/diff.py // encoding:base64
LS0tIGJ6cmxpYi9kaWZmLnB5CisrKyBienJsaWIvZGlmZi5weQpAQCAtMTY2LDggKzE2Niw5IEBA
CiAgICAgICAgICAgICAjICdkaWZmJyBnaXZlcyByZXRjb2RlID09IDIgZm9yIGFsbCBzb3J0cyBv
ZiBlcnJvcnMKICAgICAgICAgICAgICMgb25lIG9mIHRob3NlIGlzICdCaW5hcnkgZmlsZXMgZGlm
ZmVyJy4KICAgICAgICAgICAgICMgQmFkIG9wdGlvbnMgY291bGQgYWxzbyBiZSB0aGUgcHJvYmxl
bS4KLSAgICAgICAgICAgICMgJ0JpbmFyeSBmaWxlcycgaXMgbm90IGEgcmVhbCBlcnJvciwgc28g
d2Ugc3VwcHJlc3MgdGhhdCBlcnJvcgotICAgICAgICAgICAgbSA9IHJlLm1hdGNoKCdeYmluYXJ5
IGZpbGVzLipkaWZmZXIkJywgZmlyc3RfbGluZSwgcmUuSSkKKyAgICAgICAgICAgICMgJ0JpbmFy
eSBmaWxlcycgaXMgbm90IGEgcmVhbCBlcnJvciwgc28gd2Ugc3VwcHJlc3MgdGhhdCBlcnJvci4K
KyAgICAgICAgICAgICMgU3RhcnRpbmcgd2l0aCBkaWZmdXRpbHMgMi44LjQgdGhlIHdvcmQgImJp
bmFyeSIgd2FzIGRyb3BwZWQuCisgICAgICAgICAgICBtID0gcmUubWF0Y2goJ14oYmluYXJ5ICk/
ZmlsZXMuKmRpZmZlciQnLCBmaXJzdF9saW5lLCByZS5JKQogICAgICAgICAgICAgaWYgbm90IG06
CiAgICAgICAgICAgICAgICAgcmFpc2UgQnpyRXJyb3IoJ2V4dGVybmFsIGRpZmYgZmFpbGVkIHdp
dGggZXhpdCBjb2RlIDI7JwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICcgY29tbWFu
ZDogJXInICUgKGRpZmZjbWQsKSkKCg==

# revision id: marienz at gentoo.org-20060824174709-83cf7a51d41c69f8
# sha1: a7a4000ddb2b723ba82c62a11104c4ed354abe13
# inventory sha1: 03cc983b5e08ffbcdbb02fba0f4733c973d0a554
# parent ids:
#   pqm at pqm.ubuntu.com-20060811102108-06a24f3a1d4e7d82
# properties:
#   branch-nick: bzr.0.9

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060825/0b22aca7/attachment.pgp 


More information about the bazaar mailing list