1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-06-19 08:59:09 +02:00

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>
This commit is contained in:
Pete Wyckoff 2012-04-29 20:57:16 -04:00 committed by Junio C Hamano
parent 0f224e5b73
commit b6ad6dcc3b
3 changed files with 20 additions and 5 deletions

View File

@ -1038,6 +1038,7 @@ def applyCommit(self, id):
filesToAdd = set() filesToAdd = set()
filesToDelete = set() filesToDelete = set()
editedFiles = set() editedFiles = set()
pureRenameCopy = set()
filesToChangeExecBit = {} filesToChangeExecBit = {}
for line in diff: for line in diff:
@ -1061,10 +1062,13 @@ def applyCommit(self, id):
elif modifier == "C": elif modifier == "C":
src, dest = diff['src'], diff['dst'] src, dest = diff['src'], diff['dst']
p4_integrate(src, dest) p4_integrate(src, dest)
pureRenameCopy.add(dest)
if diff['src_sha1'] != diff['dst_sha1']: if diff['src_sha1'] != diff['dst_sha1']:
p4_edit(dest) p4_edit(dest)
pureRenameCopy.discard(dest)
if isModeExecChanged(diff['src_mode'], diff['dst_mode']): if isModeExecChanged(diff['src_mode'], diff['dst_mode']):
p4_edit(dest) p4_edit(dest)
pureRenameCopy.discard(dest)
filesToChangeExecBit[dest] = diff['dst_mode'] filesToChangeExecBit[dest] = diff['dst_mode']
os.unlink(dest) os.unlink(dest)
editedFiles.add(dest) editedFiles.add(dest)
@ -1073,6 +1077,8 @@ def applyCommit(self, id):
p4_integrate(src, dest) p4_integrate(src, dest)
if diff['src_sha1'] != diff['dst_sha1']: if diff['src_sha1'] != diff['dst_sha1']:
p4_edit(dest) p4_edit(dest)
else:
pureRenameCopy.add(dest)
if isModeExecChanged(diff['src_mode'], diff['dst_mode']): if isModeExecChanged(diff['src_mode'], diff['dst_mode']):
p4_edit(dest) p4_edit(dest)
filesToChangeExecBit[dest] = diff['dst_mode'] filesToChangeExecBit[dest] = diff['dst_mode']
@ -1226,6 +1232,12 @@ def applyCommit(self, id):
# unmarshalled. # unmarshalled.
changelist = self.lastP4Changelist() changelist = self.lastP4Changelist()
self.modifyChangelistUser(changelist, p4User) 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: else:
# skip this patch # skip this patch
print "Submission cancelled, undoing p4 changes." print "Submission cancelled, undoing p4 changes."

View File

@ -158,7 +158,8 @@ test_expect_success 'submit copy' '
) && ) &&
( (
cd "$cli" && cd "$cli" &&
test_path_is_file file5.ta test_path_is_file file5.ta &&
test ! -w file5.ta
) )
' '
@ -176,7 +177,8 @@ test_expect_success 'submit rename' '
( (
cd "$cli" && cd "$cli" &&
test_path_is_missing file6.t && test_path_is_missing file6.t &&
test_path_is_file file6.ta test_path_is_file file6.ta &&
test ! -w file6.ta
) )
' '

View File

@ -349,7 +349,8 @@ test_expect_success 'subdir clone, submit copy' '
) && ) &&
( (
cd "$cli" && cd "$cli" &&
test_path_is_file dir1/file11a test_path_is_file dir1/file11a &&
test ! -w dir1/file11a
) )
' '
@ -368,14 +369,14 @@ test_expect_success 'subdir clone, submit rename' '
( (
cd "$cli" && cd "$cli" &&
test_path_is_missing dir1/file13 && test_path_is_missing dir1/file13 &&
test_path_is_file dir1/file13a test_path_is_file dir1/file13a &&
test ! -w dir1/file13a
) )
' '
test_expect_success 'reinit depot' ' test_expect_success 'reinit depot' '
( (
cd "$cli" && cd "$cli" &&
p4 sync -f &&
rm files && rm files &&
p4 delete */* && p4 delete */* &&
p4 submit -d "delete all files" && p4 submit -d "delete all files" &&