tests/test-largefiles-cache.t
author Martin Geisler <mg@aragost.com>
Thu, 23 Feb 2012 13:22:55 +0100
branchstable
changeset 16153 05197f9fd1f3
parent 15916 c96148346af8
child 16154 9b072a5f8f92
permissions -rw-r--r--
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.

  $ "$TESTDIR/hghave" unix-permissions || exit 80

Create user cache directory

  $ USERCACHE=`pwd`/cache; export USERCACHE
  $ cat <<EOF >> ${HGRCPATH}
  > [extensions]
  > hgext.largefiles=
  > [largefiles]
  > usercache=${USERCACHE}
  > EOF
  $ mkdir -p ${USERCACHE}

Create source repo, and commit adding largefile.

  $ hg init src
  $ cd src
  $ echo large > large
  $ hg add --large large
  $ hg commit -m 'add largefile'
  $ cd ..

Discard all cached largefiles in USERCACHE

  $ rm -rf ${USERCACHE}

Create mirror repo, and pull from source without largefile:
"pull" is used instead of "clone" for suppression of (1) updating to
tip (= cahcing largefile from source repo), and (2) recording source
repo as "default" path in .hg/hgrc.

  $ hg init mirror
  $ cd mirror
  $ hg pull ../src
  pulling from ../src
  requesting all changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 1 changes to 1 files
  (run 'hg update' to get a working copy)
  caching new largefiles
  0 largefiles cached

Update working directory to "tip", which requires largefile("large"),
but there is no cache file for it.  So, hg must treat it as
"missing"(!) file.

  $ hg update
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  getting changed largefiles
  large: Can't get file locally
  (no default or default-push path set in hgrc)
  0 largefiles updated, 0 removed
  $ hg status
  ! large

Update working directory to null: this cleanup .hg/largefiles/dirstate

  $ hg update null
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  getting changed largefiles
  0 largefiles updated, 0 removed

Update working directory to tip, again.

  $ hg update
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  getting changed largefiles
  large: Can't get file locally
  (no default or default-push path set in hgrc)
  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