~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests/shelf_tests.py

  • Committer: Aaron Bentley
  • Date: 2007-03-16 17:59:43 UTC
  • mfrom: (524 bzrtools)
  • mto: This revision was merged to the branch mainline in revision 530.
  • Revision ID: abentley@panoramicfeedback.com-20070316175943-t6lh5aaesomyng85
Merge fixes from bzrtools-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
    UnshelveHunkSelector,
8
8
    )
9
9
from bzrlib.plugins.bzrtools.errors import NoColor
10
 
from bzrlib.plugins.bzrtools import cmd_shelf
11
10
 
12
11
 
13
12
class ShelfTests(bzrlib.tests.TestCaseWithTransport):
77
76
    def __test_loop(self, count):
78
77
        self.tree = self.make_branch_and_tree('.')
79
78
        self.__create_and_add_test_file()
80
 
        for counter in range(count):
81
 
            # Modify the test file
82
 
            # write in binary mode because on win32 line-endings should be
83
 
            # LF
84
 
            f = file('test_file', 'wb')
85
 
            f.write(self.MODIFIED)
86
 
            f.close()
87
 
 
88
 
            self._check_diff()
89
 
 
90
 
            self.tree.lock_write()
91
 
            try:
 
79
        self.tree.lock_write()
 
80
        try:
 
81
            while count > 0:
 
82
                count -= 1
 
83
 
 
84
                # Modify the test file
 
85
                # write in binary mode because on win32 line-endings should be
 
86
                # LF
 
87
                f = file('test_file', 'wb')
 
88
                f.write(self.MODIFIED)
 
89
                f.close()
 
90
 
 
91
                self._check_diff()
 
92
 
92
93
                new_date = _patch_header_date(self.tree,
93
94
                    self.tree.inventory.path2id('test_file'), 'test_file')
94
 
            finally:
95
 
                self.tree.unlock()
96
 
 
97
 
            # Shelve the changes
98
 
            self.run_bzr('shelve', '--all', retcode=0)
99
 
 
100
 
            # Make sure there is no diff anymore
101
 
            self.assertEqual(self.capture('diff', retcode=0), '')
102
 
 
103
 
            # Make sure the file is actually back the way it was
104
 
            self.assertEqual(file('test_file').read(), self.ORIGINAL)
105
 
 
106
 
            self._check_shelf('00', new_date=new_date)
107
 
 
108
 
            # Unshelve
109
 
            self.run_bzr('unshelve', '--all', retcode=0)
110
 
 
111
 
            self._check_diff()
112
 
 
113
 
            # Check the shelved patch was backed up
114
 
            self._check_shelf('00~', new_date=new_date)
115
 
 
116
 
            # Make sure the file is back the way it should be
117
 
            self.assertEqual(file('test_file').read(), self.MODIFIED)
 
95
 
 
96
                # Shelve the changes
 
97
                self.run_bzr('shelve', '--all', retcode=0)
 
98
 
 
99
                # Make sure there is no diff anymore
 
100
                self.assertEqual(self.capture('diff', retcode=0), '')
 
101
 
 
102
                # Make sure the file is actually back the way it was
 
103
                self.assertEqual(file('test_file').read(), self.ORIGINAL)
 
104
 
 
105
                self._check_shelf('00', new_date=new_date)
 
106
 
 
107
                # Unshelve
 
108
                self.run_bzr('unshelve', '--all', retcode=0)
 
109
 
 
110
                self._check_diff()
 
111
 
 
112
                # Check the shelved patch was backed up
 
113
                self._check_shelf('00~', new_date=new_date)
 
114
 
 
115
                # Make sure the file is back the way it should be
 
116
                self.assertEqual(file('test_file').read(), self.MODIFIED)
 
117
        finally:
 
118
            self.tree.unlock()
118
119
 
119
120
    def test_shelf_nothing_to_shelve(self):
120
121
        import os.path
617
618
                                               '--no-color'])
618
619
        stdout, error = self.run_bzr_captured(['unshelve', '--all', 
619
620
                                               '--no-color'])
620
 
 
621
 
    def test_shelf_help(self):
622
 
        self.assertContainsRe(cmd_shelf().help(),
623
 
                              'list\n.*List the patches on the current shelf')