Rev 4790: It seems that on Win32, if you open a file with FILE_SHARE_READ in http://bazaar.launchpad.net/~jameinel/bzr/2.1.0b4-win32-append-read-locked

John Arbash Meinel john at arbash-meinel.com
Sun Nov 8 05:00:34 GMT 2009


At http://bazaar.launchpad.net/~jameinel/bzr/2.1.0b4-win32-append-read-locked

------------------------------------------------------------
revno: 4790
revision-id: john at arbash-meinel.com-20091108050024-zpmrgqwa6hszlfsg
parent: pqm at pqm.ubuntu.com-20091106084512-t5ll6xywcd1bycfe
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1.0b4-win32-append-read-locked
timestamp: Sat 2009-11-07 23:00:24 -0600
message:
  It seems that on Win32, if you open a file with FILE_SHARE_READ
  it prevents you from also opening that file in 'ab' mode.
  
  At least, that is now true on Windows Vista and the new _CreateFile style locks.
-------------- next part --------------
=== modified file 'bzrlib/tests/test__dirstate_helpers.py'
--- a/bzrlib/tests/test__dirstate_helpers.py	2009-06-22 15:39:42 +0000
+++ b/bzrlib/tests/test__dirstate_helpers.py	2009-11-08 05:00:24 +0000
@@ -743,13 +743,17 @@
 
     def test_trailing_garbage(self):
         tree, state, expected = self.create_basic_dirstate()
-        # We can modify the file as long as it hasn't been read yet.
+        # On Linux, we can write extra data as long as we haven't read yet, but
+        # on Win32, if you've opened the file with FILE_SHARE_READ, trying to
+        # open it in append mode will fail.
+        state.unlock()
         f = open('dirstate', 'ab')
         try:
             # Add bogus trailing garbage
             f.write('bogus\n')
         finally:
             f.close()
+            state.lock_read()
         e = self.assertRaises(errors.DirstateCorrupt,
                               state._read_dirblocks_if_needed)
         # Make sure we mention the bogus characters in the error



More information about the bazaar-commits mailing list