summaryrefslogtreecommitdiff
path: root/git-p4.py
diff options
context:
space:
mode:
authorPete Wyckoff <pw@padd.com>2013-01-27 03:11:19 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-01-27 06:00:39 (GMT)
commitd20f0f8e2804bedc2c3743b523724ba7b8d34264 (patch)
treef276d94855c71c9d95a58513abcd41093cc676d9 /git-p4.py
parent4cea4d66083f0f9116674f7ca54418f61bcf17b9 (diff)
downloadgit-d20f0f8e2804bedc2c3743b523724ba7b8d34264.zip
git-d20f0f8e2804bedc2c3743b523724ba7b8d34264.tar.gz
git-d20f0f8e2804bedc2c3743b523724ba7b8d34264.tar.bz2
git p4: disable read-only attribute before deleting
On windows, p4 marks un-edited files as read-only. Not only are they read-only, but also they cannot be deleted. Remove the read-only attribute before deleting in both the copy and rename cases. This also happens in the RCS cleanup code, where a file is marked to be deleted, but must first be edited to remove adjust the keyword lines. Make sure it is editable before patching. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-p4.py')
-rwxr-xr-xgit-p4.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/git-p4.py b/git-p4.py
index c62b2ca..a989704 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -21,6 +21,7 @@ import time
import platform
import re
import shutil
+import stat
verbose = False
@@ -1231,6 +1232,9 @@ class P4Submit(Command, P4UserMap):
p4_edit(dest)
pureRenameCopy.discard(dest)
filesToChangeExecBit[dest] = diff['dst_mode']
+ if self.isWindows:
+ # turn off read-only attribute
+ os.chmod(dest, stat.S_IWRITE)
os.unlink(dest)
editedFiles.add(dest)
elif modifier == "R":
@@ -1249,6 +1253,8 @@ class P4Submit(Command, P4UserMap):
p4_edit(dest) # with move: already open, writable
filesToChangeExecBit[dest] = diff['dst_mode']
if not self.p4HasMoveCommand:
+ if self.isWindows:
+ os.chmod(dest, stat.S_IWRITE)
os.unlink(dest)
filesToDelete.add(src)
editedFiles.add(dest)
@@ -1289,6 +1295,10 @@ class P4Submit(Command, P4UserMap):
for file in kwfiles:
if verbose:
print "zapping %s with %s" % (line,pattern)
+ # File is being deleted, so not open in p4. Must
+ # disable the read-only bit on windows.
+ if self.isWindows and file not in editedFiles:
+ os.chmod(file, stat.S_IWRITE)
self.patchRCSKeywords(file, kwfiles[file])
fixed_rcs_keywords = True