~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transform.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-03-22 09:57:11 UTC
  • mfrom: (5724.1.4 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20110322095711-9bggm9tnxnw9frow
(jameinel) Fix tar exporters to always write to binary streams. (John A
 Meinel)

Show diffs side-by-side

added added

removed removed

Lines of Context:
161
161
        transform.finalize()
162
162
        transform.finalize()
163
163
 
164
 
    def test_create_file_caches_sha1(self):
165
 
        trans, root = self.get_transform()
166
 
        self.wt.lock_tree_write()
167
 
        self.addCleanup(self.wt.unlock)
168
 
        content = ['just some content\n']
169
 
        sha1 = osutils.sha_strings(content)
170
 
        trans_id = trans.create_path('file1', root)
171
 
        # Roll back the clock
172
 
        transform._creation_mtime = creation_mtime = time.time() - 20.0
173
 
        trans.create_file(content, trans_id, sha1=sha1)
174
 
        st_val = osutils.lstat(trans._limbo_name(trans_id))
175
 
        o_sha1, o_st_val = trans._observed_sha1s[trans_id]
176
 
        self.assertEqual(o_sha1, sha1)
177
 
        self.assertEqualStat(o_st_val, st_val)
178
 
 
179
 
    def test__apply_insertions_updates_sha1(self):
180
 
        trans, root = self.get_transform()
181
 
        self.wt.lock_tree_write()
182
 
        self.addCleanup(self.wt.unlock)
183
 
        content = ['just some content\n']
184
 
        sha1 = osutils.sha_strings(content)
185
 
        trans_id = trans.create_path('file1', root)
186
 
        # Roll back the clock
187
 
        transform._creation_mtime = creation_mtime = time.time() - 20.0
188
 
        trans.create_file(content, trans_id, sha1=sha1)
189
 
        st_val = osutils.lstat(trans._limbo_name(trans_id))
190
 
        o_sha1, o_st_val = trans._observed_sha1s[trans_id]
191
 
        self.assertEqual(o_sha1, sha1)
192
 
        self.assertEqualStat(o_st_val, st_val)
193
 
        creation_mtime += 10.0
194
 
        # We fake a time difference from when the file was created until now it
195
 
        # is being renamed by using os.utime. Note that the change we actually
196
 
        # want to see is the real ctime change from 'os.rename()', but as long
197
 
        # as we observe a new stat value, we should be fine.
198
 
        os.utime(trans._limbo_name(trans_id), (creation_mtime, creation_mtime))
199
 
        trans.apply()
200
 
        new_st_val = osutils.lstat(self.wt.abspath('file1'))
201
 
        o_sha1, o_st_val = trans._observed_sha1s[trans_id]
202
 
        self.assertEqual(o_sha1, sha1)
203
 
        self.assertEqualStat(o_st_val, new_st_val)
204
 
        self.assertNotEqual(st_val.st_mtime, new_st_val.st_mtime)
205
 
 
206
164
    def test_create_files_same_timestamp(self):
207
165
        transform, root = self.get_transform()
208
166
        self.wt.lock_tree_write()