Rev 3087: (John Arbash Meinel) Fix internal_diff to not abort when the texts in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Dec 6 17:57:12 GMT 2007


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 3087
revision-id:pqm at pqm.ubuntu.com-20071206175705-a3go0hme7nx1rr69
parent: pqm at pqm.ubuntu.com-20071206135045-uhim2fpy9d2n4esa
parent: john at arbash-meinel.com-20071206140707-gl2q6ukle2u1sb5x
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2007-12-06 17:57:05 +0000
message:
  (John Arbash Meinel) Fix internal_diff to not abort when the texts
  	are identical.
modified:
  bzrlib/diff.py                 diff.py-20050309040759-26944fbbf2ebbf36
  bzrlib/tests/test_diff.py      testdiff.py-20050727164403-d1a3496ebb12e339
    ------------------------------------------------------------
    revno: 3085.1.1
    revision-id:john at arbash-meinel.com-20071206140707-gl2q6ukle2u1sb5x
    parent: pqm at pqm.ubuntu.com-20071206063448-0fk3ky25yb3lwxi8
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: internal_diff_no_changes
    timestamp: Thu 2007-12-06 08:07:07 -0600
    message:
      Fix internal_diff to not fail when the texts are identical.
      Related to bug #174337
    modified:
      bzrlib/diff.py                 diff.py-20050309040759-26944fbbf2ebbf36
      bzrlib/tests/test_diff.py      testdiff.py-20050727164403-d1a3496ebb12e339
=== modified file 'bzrlib/diff.py'
--- a/bzrlib/diff.py	2007-11-27 13:57:29 +0000
+++ b/bzrlib/diff.py	2007-12-06 14:07:07 +0000
@@ -86,6 +86,8 @@
                       sequencematcher=sequence_matcher)
 
     ud = list(ud)
+    if len(ud) == 0: # Identical contents, nothing to do
+        return
     # work-around for difflib being too smart for its own good
     # if /dev/null is "1,0", patch won't recognize it as /dev/null
     if not oldlines:

=== modified file 'bzrlib/tests/test_diff.py'
--- a/bzrlib/tests/test_diff.py	2007-11-25 21:52:24 +0000
+++ b/bzrlib/tests/test_diff.py	2007-12-06 14:07:07 +0000
@@ -239,6 +239,18 @@
                           ]
                           , lines)
 
+    def test_internal_diff_no_content(self):
+        output = StringIO()
+        internal_diff(u'old', [], u'new', [], output)
+        self.assertEqual('', output.getvalue())
+
+    def test_internal_diff_no_changes(self):
+        output = StringIO()
+        internal_diff(u'old', ['text\n', 'contents\n'],
+                      u'new', ['text\n', 'contents\n'],
+                      output)
+        self.assertEqual('', output.getvalue())
+
     def test_internal_diff_returns_bytes(self):
         import StringIO
         output = StringIO.StringIO()




More information about the bazaar-commits mailing list