Mercurial > hg-stable
changeset 16153:05197f9fd1f3 stable
largefiles: use repo.store.createmode for new files in .hg/largefiles
Before, the mode was copied from the file in the working copy. This is
inconsistent with how Mercurial normally creates files inside the .hg
folder. This can lead to a situation where you can read the files
under .hg/store but not under .hg/largefiles and so a clone will fail
if it needs to access a largefile.
author | Martin Geisler <mg@aragost.com> |
---|---|
date | Thu, 23 Feb 2012 13:22:55 +0100 |
parents | 616c2e278f18 |
children | 9b072a5f8f92 |
files | hgext/largefiles/lfutil.py tests/test-largefiles-cache.t |
diffstat | 2 files changed, 26 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/largefiles/lfutil.py Thu Feb 23 00:07:54 2012 +0900 +++ b/hgext/largefiles/lfutil.py Thu Feb 23 13:22:55 2012 +0100 @@ -237,11 +237,11 @@ if inusercache(repo.ui, hash): link(usercachepath(repo.ui, hash), storepath(repo, hash)) else: - dst = util.atomictempfile(storepath(repo, hash)) + dst = util.atomictempfile(storepath(repo, hash), + createmode=repo.store.createmode) for chunk in util.filechunkiter(open(file, 'rb')): dst.write(chunk) dst.close() - util.copymode(file, storepath(repo, hash)) linktousercache(repo, hash) def linktousercache(repo, hash):
--- a/tests/test-largefiles-cache.t Thu Feb 23 00:07:54 2012 +0900 +++ b/tests/test-largefiles-cache.t Thu Feb 23 13:22:55 2012 +0100 @@ -1,3 +1,5 @@ + $ "$TESTDIR/hghave" unix-permissions || exit 80 + Create user cache directory $ USERCACHE=`pwd`/cache; export USERCACHE @@ -70,3 +72,25 @@ 0 largefiles updated, 0 removed $ hg status ! large + +Portable way to print file permissions: + + $ cd .. + $ cat > ls-l.py <<EOF + > #!/usr/bin/env python + > import sys, os + > path = sys.argv[1] + > print '%03o' % (os.lstat(path).st_mode & 0777) + > EOF + $ chmod +x ls-l.py + +Test that files in .hg/largefiles inherit mode from .hg/store, not +from file in working copy: + + $ cd src + $ chmod 750 .hg/store + $ chmod 660 large + $ echo change >> large + $ hg commit -m change + $ ../ls-l.py .hg/largefiles/e151b474069de4ca6898f67ce2f2a7263adf8fea + 640