Rev 5453: (gz) Allow arbitrary bytes for unshelve diffs rather than throwing in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Oct 1 08:40:20 BST 2010


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

------------------------------------------------------------
revno: 5453 [merge]
revision-id: pqm at pqm.ubuntu.com-20101001074020-arbz6k0sl3w7nlrm
parent: pqm at pqm.ubuntu.com-20100929220303-cr95h8iwtggco721
parent: polymorphm at gmail.com-20100930002907-5gssicrhqeb6dqie
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2010-10-01 08:40:20 +0100
message:
  (gz) Allow arbitrary bytes for unshelve diffs rather than throwing
   UnicodeDecodeError on non-ascii contents (Andrej A Antonov)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/shelf_ui.py             shelver.py-20081005210102-33worgzwrtdw0yrm-1
  bzrlib/tests/blackbox/test_shelve.py test_ls_shelf.py-20081202053526-thlo8yt0pi1cgor1-1
=== modified file 'NEWS'
--- a/NEWS	2010-09-29 22:03:03 +0000
+++ b/NEWS	2010-09-30 00:29:07 +0000
@@ -41,6 +41,9 @@
 * Skip the tests that requires respecting the chmod bits when running as root.
   (Vincent Ladeuil, #646133)
 
+* ``unshelve --preview`` now can show diff in a non-ascii encoding.
+  (Andrej A Antonov, #518916)
+
 Improvements
 ************
 

=== modified file 'bzrlib/shelf_ui.py'
--- a/bzrlib/shelf_ui.py	2010-07-16 13:29:07 +0000
+++ b/bzrlib/shelf_ui.py	2010-09-20 23:15:01 +0000
@@ -493,7 +493,7 @@
         tt = tree_merger.make_preview_transform()
         new_tree = tt.get_preview_tree()
         if self.write_diff_to is None:
-            self.write_diff_to = ui.ui_factory.make_output_stream()
+            self.write_diff_to = ui.ui_factory.make_output_stream(encoding_type='exact')
         path_encoding = osutils.get_diff_header_encoding()
         diff.show_diff_trees(merger.this_tree, new_tree, self.write_diff_to,
             path_encoding=path_encoding)

=== modified file 'bzrlib/tests/blackbox/test_shelve.py'
--- a/bzrlib/tests/blackbox/test_shelve.py	2010-05-28 14:15:28 +0000
+++ b/bzrlib/tests/blackbox/test_shelve.py	2010-09-29 12:58:17 +0000
@@ -87,6 +87,25 @@
 contents of file
 ''')
 
+class TestUnshelvePreview(TestCaseWithTransport):
+    
+    def test_non_ascii(self):
+        """Test that we can show a non-ascii diff that would result from unshelving"""
+        
+        init_content = u'Initial: \u0418\u0437\u043d\u0430\u0447\n'.encode('utf-8')
+        more_content = u'More: \u0415\u0449\u0451\n'.encode('utf-8')
+        next_content = init_content + more_content
+        diff_part = '@@ -1,1 +1,2 @@\n %s+%s' % (init_content, more_content)
+        
+        tree = self.make_branch_and_tree('.')
+        self.build_tree_contents([('a_file', init_content)])
+        tree.add('a_file')
+        tree.commit(message='committed')
+        self.build_tree_contents([('a_file', next_content)])
+        self.run_bzr(['shelve', '--all'])
+        out, err = self.run_bzr(['unshelve', '--preview'], encoding='latin-1')
+        
+        self.assertContainsString(out, diff_part)
 
 
 class TestShelveRelpath(TestCaseWithTransport):




More information about the bazaar-commits mailing list