mercurial/osutil.c
changeset 13273 764441ecbf2e
parent 11359 4eaacccbb2ca
child 13297 613b8bd2284e
--- a/mercurial/osutil.c	Tue Jan 04 06:29:08 2011 +0100
+++ b/mercurial/osutil.c	Sat Jan 15 23:54:01 2011 +0100
@@ -436,7 +436,14 @@
 	}
 	else
 		flags = _O_TEXT;
-	if (plus) {
+	if (m0 == 'r' && !plus) {
+		flags |= _O_RDONLY;
+		access = GENERIC_READ;
+	} else {
+		/*
+		work around http://support.microsoft.com/kb/899149 and
+		set _O_RDWR for 'w' and 'a', even if mode has no '+'
+		*/
 		flags |= _O_RDWR;
 		access = GENERIC_READ | GENERIC_WRITE;
 		fpmode[fppos++] = '+';
@@ -446,25 +453,13 @@
 	switch (m0) {
 	case 'r':
 		creation = OPEN_EXISTING;
-		if (!plus) {
-			flags |= _O_RDONLY;
-			access = GENERIC_READ;
-		}
 		break;
 	case 'w':
 		creation = CREATE_ALWAYS;
-		if (!plus) {
-			access = GENERIC_WRITE;
-			flags |= _O_WRONLY;
-		}
 		break;
 	case 'a':
 		creation = OPEN_ALWAYS;
 		flags |= _O_APPEND;
-		if (!plus) {
-			flags |= _O_WRONLY;
-			access = GENERIC_WRITE;
-		}
 		break;
 	default:
 		PyErr_Format(PyExc_ValueError,