Skip to content

Commit

Permalink
subtree: fix file mode for subtree copied files
Browse files Browse the repository at this point in the history
Summary:
Fix the file mode for subtree copied files by calling 'util.setflags'. 'util.setflags' is not needed for
symlinks. Since symlink itself does not have independent permissions; its permissions are
determined by the target file.

Reviewed By: muirdm

Differential Revision: D67408658

fbshipit-source-id: 932b068a08b8cceb4853bc8d31717e72555b97bd
  • Loading branch information
zzl0 authored and facebook-github-bot committed Dec 19, 2024
1 parent 7217f74 commit 0157717
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions eden/scm/sapling/commands/subtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
progress,
registrar,
scmutil,
util,
)
from ..cmdutil import (
commitopts,
Expand Down Expand Up @@ -447,6 +448,8 @@ def prefetch(repo, path, fileids):
else:
with open(os_abs_dest, "wb") as f:
f.write(fctx.data())
if fctx.isexec():
util.setflags(os_abs_dest, l=False, x=True)

wctx = repo[None]
wctx.add(new_files)
Expand Down
24 changes: 24 additions & 0 deletions eden/scm/tests/test-subtree.t
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,30 @@ test subtree copy with symlinks
$ cat foo2/b
aaa

#if execbit
test subtree copy with execs
$ newclientrepo
$ mkdir foo
$ echo "aaa" > foo/a
$ chmod +x foo/a
$ echo "bbb" > foo/b
$ hg ci -Aqm 'first'
$ echo "bbb" > foo/a
$ hg ci -m 'second'
$ hg subtree cp -r "desc(first)" --from-path foo --to-path foo2
copying foo to foo2
$ f -m foo/a foo/b foo2/a foo2/b
foo/a: mode=755
foo/b: mode=644
foo2/a: mode=755
foo2/b: mode=644
$ hg dbsh -c 'for x in ["foo/a", "foo/b", "foo2/a", "foo2/b"]: print([x, repo["."].manifest().flags(x)])'
['foo/a', 'x']
['foo/b', '']
['foo2/a', 'x']
['foo2/b', '']
#endif

test subtree copy to tracked directory
$ newclientrepo
$ drawdag <<'EOS'
Expand Down

0 comments on commit 0157717

Please sign in to comment.