aboutsummaryrefslogtreecommitdiff
path: root/git-p4.py
diff options
context:
space:
mode:
authorPete Wyckoff <pw@padd.com>2012-04-29 20:57:16 -0400
committerJunio C Hamano <gitster@pobox.com>2012-04-30 16:00:04 -0700
commitb6ad6dcc3b0629d525abc9fe0882e1b0eb969e17 (patch)
tree9f00b39820b05293dd65097c8aaf5823c77654ea /git-p4.py
parent0f224e5b73a73f37887eb7cb3e51073f889a3f9c (diff)
downloadgit-b6ad6dcc3b0629d525abc9fe0882e1b0eb969e17.tar.gz
git-b6ad6dcc3b0629d525abc9fe0882e1b0eb969e17.tar.xz
git p4: fix writable file after rename or copy
The way rename works is with a "p4 integrate", optionally followed by a "p4 edit" if the change is not a 100% rename. Contents are generated by applying a patch, not doing a file system rename. Copy is similar. In this case, p4 does not fix the permissions back to read-only. Make sure this happens by calling "p4 sync -f". 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.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/git-p4.py b/git-p4.py
index a22354ae8..2d83aa883 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -1038,6 +1038,7 @@ class P4Submit(Command, P4UserMap):
filesToAdd = set()
filesToDelete = set()
editedFiles = set()
+ pureRenameCopy = set()
filesToChangeExecBit = {}
for line in diff:
@@ -1061,10 +1062,13 @@ class P4Submit(Command, P4UserMap):
elif modifier == "C":
src, dest = diff['src'], diff['dst']
p4_integrate(src, dest)
+ pureRenameCopy.add(dest)
if diff['src_sha1'] != diff['dst_sha1']:
p4_edit(dest)
+ pureRenameCopy.discard(dest)
if isModeExecChanged(diff['src_mode'], diff['dst_mode']):
p4_edit(dest)
+ pureRenameCopy.discard(dest)
filesToChangeExecBit[dest] = diff['dst_mode']
os.unlink(dest)
editedFiles.add(dest)
@@ -1073,6 +1077,8 @@ class P4Submit(Command, P4UserMap):
p4_integrate(src, dest)
if diff['src_sha1'] != diff['dst_sha1']:
p4_edit(dest)
+ else:
+ pureRenameCopy.add(dest)
if isModeExecChanged(diff['src_mode'], diff['dst_mode']):
p4_edit(dest)
filesToChangeExecBit[dest] = diff['dst_mode']
@@ -1226,6 +1232,12 @@ class P4Submit(Command, P4UserMap):
# unmarshalled.
changelist = self.lastP4Changelist()
self.modifyChangelistUser(changelist, p4User)
+
+ # The rename/copy happened by applying a patch that created a
+ # new file. This leaves it writable, which confuses p4.
+ for f in pureRenameCopy:
+ p4_sync(f, "-f")
+
else:
# skip this patch
print "Submission cancelled, undoing p4 changes."