Fix mode setting in the case of moved executable files

This commit is contained in:
David Turner
2016-11-14 18:13:56 -05:00
parent a35f93cbc1
commit e8c88c70d9
2 changed files with 27 additions and 11 deletions

View File

@@ -778,17 +778,7 @@ def get_file_metadata(repo, p1, files):
if 'rename' in f and 'mode' not in f: if 'rename' in f and 'mode' not in f:
old = f['rename'] old = f['rename']
ctx = repo[p1][old] ctx = repo[p1][old]
m = '' f['mode'] = ctx.flags()
# .isexec(), .islink() only around in newer versions
if hasattr(ctx, 'isexec'):
m = ctx.isexec()
else:
m = ('x' in ctx.flags())
if hasattr(ctx, 'islink'):
m = ctx.islink()
else:
m = ('l' in ctx.flags())
f['mode'] = m
f['data'] = ctx.data() f['data'] = ctx.data()
def get_merge_files(repo, p1, p2, files): def get_merge_files(repo, p1, p2, files):

View File

@@ -251,6 +251,32 @@ test_expect_success 'shared-marks unset to set' '
) )
' '
test_expect_success 'push with renamed executable preserves executable bit' '
test_when_finished "rm -rf hgrepo gitrepo*" &&
hg init hgrepo &&
(
git init gitrepo &&
cd gitrepo &&
git remote add origin "hg::../hgrepo" &&
echo one > content &&
chmod a+x content &&
git add content &&
git commit -a -m one &&
git mv content content2 &&
git commit -a -m two &&
git push origin master
) &&
(
cd hgrepo &&
hg update &&
stat content2 >expected &&
grep -- -rwxr-xr-x expected
)
'
# cleanup setting # cleanup setting
git config --global --unset remote-hg.shared-marks git config --global --unset remote-hg.shared-marks