~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_dirstate.py

Merge bzr.dev to resolve conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
1351
1351
        stat = os.lstat(path)
1352
1352
        return dirstate.update_entry(state, entry, os.path.abspath(path), stat)
1353
1353
 
 
1354
    def _read_state_content(self, state):
 
1355
        """Read the content of the dirstate file.
 
1356
 
 
1357
        On Windows when one process locks a file, you can't even open() the
 
1358
        file in another process (to read it). So we go directly to
 
1359
        state._state_file. This should always be the exact disk representation,
 
1360
        so it is reasonable to do so.
 
1361
        DirState also always seeks before reading, so it doesn't matter if we
 
1362
        bump the file pointer.
 
1363
        """
 
1364
        state._state_file.seek(0)
 
1365
        return state._state_file.read()
 
1366
 
1354
1367
    def test_worth_saving_limit_avoids_writing(self):
1355
1368
        tree = self.make_branch_and_tree('.')
1356
1369
        self.build_tree(['c', 'd'])
1366
1379
        state.adjust_time(+20) # Allow things to be cached
1367
1380
        self.assertEqual(dirstate.DirState.IN_MEMORY_UNMODIFIED,
1368
1381
                         state._dirblock_state)
1369
 
        f = open(state._filename, 'rb')
1370
 
        try:
1371
 
            content = f.read()
1372
 
        finally:
1373
 
            f.close()
 
1382
        content = self._read_state_content(state)
1374
1383
        self.do_update_entry(state, 'c')
1375
1384
        self.assertEqual(1, len(state._known_hash_changes))
1376
1385
        self.assertEqual(dirstate.DirState.IN_MEMORY_HASH_MODIFIED,
1380
1389
        # hash values haven't been written out.
1381
1390
        self.assertEqual(dirstate.DirState.IN_MEMORY_HASH_MODIFIED,
1382
1391
                         state._dirblock_state)
1383
 
        self.assertFileEqual(content, state._filename)
 
1392
        self.assertEqual(content, self._read_state_content(state))
1384
1393
        self.assertEqual(dirstate.DirState.IN_MEMORY_HASH_MODIFIED,
1385
1394
                         state._dirblock_state)
1386
1395
        self.do_update_entry(state, 'd')