~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests.py

  • Committer: Michael Ellerman
  • Date: 2006-03-11 13:09:06 UTC
  • mto: (325.1.2 bzrtools) (0.3.1 shelf-dev)
  • mto: This revision was merged to the branch mainline in revision 334.
  • Revision ID: michael@ellerman.id.au-20060311130906-387167043c79797b
When unshelving, try to patch with --dry-run first, if that fails bail out.
This should prevent the working tree getting half of the shelved patch, but
not the rest, which seems cleaner.

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
                '.shelf/shelves/default/00')):
83
83
            self.fail("Shelf exists, but it shouldn't")
84
84
 
85
 
    def __create_and_add_test_file(self, tree):
86
 
        self.build_tree_contents([('test_file', self.ORIGINAL)])
87
 
        tree.add('test_file')
88
 
        tree.commit(message='add test_file')
 
85
    def __create_and_add_test_file(self, tree, filename='test_file'):
 
86
        self.build_tree_contents([(filename, self.ORIGINAL)])
 
87
        tree.add(filename)
 
88
        tree.commit(message='add %s' % filename)
89
89
 
90
90
    def test_shelf_with_revision(self):
91
91
        tree = self.make_branch_and_tree('.')
208
208
        shelf = open(os.path.join(tree.branch.base,
209
209
                    '.shelf/shelves/default/00')).read()
210
210
        self.assertEqual(shelf, self.DIFF_2)
 
211
 
 
212
        # Working tree should be unchanged
 
213
        diff = self.capture('diff', retcode=0)
 
214
        self.assertEqual(diff, '')
 
215
 
 
216
    def test_shelf_unshelve_failure_two_hunks(self):
 
217
        tree = self.make_branch_and_tree('.')
 
218
 
 
219
        self.__create_and_add_test_file(tree)
 
220
        self.__create_and_add_test_file(tree, filename='test_file2')
 
221
 
 
222
        # Modify the test files
 
223
        file('test_file', 'w').write(self.MODIFIED)
 
224
        file('test_file2', 'w').write(self.MODIFIED)
 
225
 
 
226
        # Shelve the changes
 
227
        self.run_bzr('shelve', retcode=0)
 
228
 
 
229
        # Put the changes to test_file back, the shelved patch won't apply now
 
230
        file('test_file', 'w').write(self.MODIFIED)
 
231
        tree.commit(message='screw up test_file')
 
232
 
 
233
        # Unshelve, should fail
 
234
        self.run_bzr('unshelve', retcode=3)
 
235
 
 
236
        # Working tree should be unchanged
 
237
        diff = self.capture('diff', retcode=0)
 
238
        self.assertEqual(diff, '')