~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests/shelf_tests.py

  • Committer: Aaron Bentley
  • Date: 2007-03-26 17:16:00 UTC
  • mfrom: (517.1.7 bzrtools-0.15)
  • Revision ID: abentley@panoramicfeedback.com-20070326171600-49ldttkuccqvbp37
MergeĀ fromĀ release

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
    def __test_loop(self, count):
77
77
        self.tree = self.make_branch_and_tree('.')
78
78
        self.__create_and_add_test_file()
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
 
 
 
79
        for counter in range(count):
 
80
            # Modify the test file
 
81
            # write in binary mode because on win32 line-endings should be
 
82
            # LF
 
83
            f = file('test_file', 'wb')
 
84
            f.write(self.MODIFIED)
 
85
            f.close()
 
86
 
 
87
            self._check_diff()
 
88
 
 
89
            self.tree.lock_write()
 
90
            try:
93
91
                new_date = _patch_header_date(self.tree,
94
92
                    self.tree.inventory.path2id('test_file'), 'test_file')
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()
 
93
            finally:
 
94
                self.tree.unlock()
 
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)
119
117
 
120
118
    def test_shelf_nothing_to_shelve(self):
121
119
        import os.path