Rev 6512: Add a failing test reproducing bug #660125. in file:///home/vila/src/bzr/bugs/660125-shelve-rename-existing/

Vincent Ladeuil v.ladeuil+lp at free.fr
Sun Oct 14 09:52:07 UTC 2012


At file:///home/vila/src/bzr/bugs/660125-shelve-rename-existing/

------------------------------------------------------------
revno: 6512
revision-id: v.ladeuil+lp at free.fr-20121014095207-77umkk5yj525dkvh
parent: pqm at pqm.ubuntu.com-20120911090908-1xx05ree9c58y4in
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 660125-shelve-rename-existing
timestamp: Sun 2012-10-14 11:52:07 +0200
message:
  Add a failing test reproducing bug #660125.
-------------- next part --------------
=== modified file 'bzrlib/tests/blackbox/test_shelve.py'
--- a/bzrlib/tests/blackbox/test_shelve.py	2011-05-13 12:51:05 +0000
+++ b/bzrlib/tests/blackbox/test_shelve.py	2012-10-14 09:52:07 +0000
@@ -16,12 +16,14 @@
 
 import os
 
-from bzrlib import shelf
-from bzrlib.tests import TestCaseWithTransport
-from bzrlib.tests.script import ScriptRunner
-
-
-class TestShelveList(TestCaseWithTransport):
+from bzrlib import (
+    shelf,
+    tests,
+    )
+from bzrlib.tests import script
+
+
+class TestShelveList(tests.TestCaseWithTransport):
 
     def test_no_shelved_changes(self):
         tree = self.make_branch_and_tree('.')
@@ -75,6 +77,9 @@
         self.assertPathDoesNotExist('file')
         self.assertIs(None, tree.get_shelf_manager().last_shelf())
 
+
+class TestUnshelveWithScripts(script.TestCaseWithTransportAndScript):
+
     def test_unshelve_keep(self):
         # https://bugs.launchpad.net/bzr/+bug/492091
         tree = self.make_branch_and_tree('.')
@@ -82,8 +87,7 @@
         tree.commit('make root')
         self.build_tree(['file'])
 
-        sr = ScriptRunner()
-        sr.run_script(self, '''
+        self.run_script('''
 $ bzr add file
 adding file
 $ bzr shelve --all -m Foo
@@ -103,16 +107,43 @@
 contents of file
 ''')
 
-class TestUnshelvePreview(TestCaseWithTransport):
-    
+class TestShelveWithScripts(script.TestCaseWithTransportAndScript):
+
+    def test_shelve_rename_existing(self):
+        self.run_script('''
+$ bzr init foo
+Created a standalone tree (format: 2a)
+$ cd foo/
+$ echo >spam
+$ bzr add
+adding spam
+$ bzr commit --message "Initial commit of foo project."
+2>Committing to: .../foo/
+2>added spam
+2>Committed revision 1.
+$ bzr mv spam beans
+spam => beans
+$ echo >spam
+''')
+        # The failing command
+        self.run_script('''
+$ bzr shelve --all
+Selected changes:
+R beans => spam
+bzr: ERROR: Tree transform is malformed [('duplicate', 'new-1', 'new-2', u'spam')]
+''')
+
+class TestUnshelvePreview(tests.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')
+        """Unshelve can show a non-ascii diff."""
+
+        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')
@@ -120,11 +151,10 @@
         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):
+class TestShelveRelpath(tests.TestCaseWithTransport):
 
     def test_shelve_in_subdir(self):
         tree = self.make_branch_and_tree('tree')
@@ -140,7 +170,7 @@
         self.run_bzr('shelve -d tree/dir --all ../file')
 
 
-class TestShelveUnshelve(TestCaseWithTransport):
+class TestShelveUnshelve(tests.TestCaseWithTransport):
 
     def test_directory(self):
         """Test --directory option"""



More information about the bazaar-commits mailing list