mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 23:38:50 +03:00
4235784907
Summary: It's not really magic because we don't have a virtual directory inode base any more. Instead, we mkdir and populate it at mount time. What is slightly magical about it is that we give it some special powers: * We know the inode number of the eden dir and prevent unlink operations on it or inside it. * The .eden dir is present in the contents of the root inode and will show up when that directory is `readdir`'d * When resolving a child of a TreeInode by name, we know to return the magic `.eden` inode number. This means that it is possible to `stat` and consume the `.eden` directory from any directory inside the eden mount, even though it won't show up in `readdir` for those child dirs. The contents of the `.eden` dir are: * `socket` - a symlink back to the unix domain socket that our thrift server is listening on. This means that it is a simple `readlink(".eden/socket")` operation to discover both whether a directory is part of an eden mount and how to talk to the server. * `root` - a symlink back to the root of this eden mount. This allows using `readlink(".eden/root")` as a simple 1-step operation to find the root of an eden mount, and avoids needing to walk up directory by directory as is the common pattern for locating `.hg` or `.git` dirs. Reviewed By: simpkins Differential Revision: D4637285 fbshipit-source-id: 0eabf98b29144acccef5c83bd367493399dc55bb
49 lines
1.6 KiB
Python
49 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
#
|
|
# Copyright (c) 2016-present, Facebook, Inc.
|
|
# All rights reserved.
|
|
#
|
|
# This source code is licensed under the BSD-style license found in the
|
|
# LICENSE file in the root directory of this source tree. An additional grant
|
|
# of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
import os
|
|
import stat
|
|
import hypothesis
|
|
from .lib import testcase
|
|
|
|
|
|
@testcase.eden_repo_test
|
|
class HypothesisSimpleTest:
|
|
def populate_repo(self):
|
|
self.repo.write_file('hello', 'hola\n')
|
|
self.repo.write_file('adir/file', 'foo!\n')
|
|
self.repo.write_file('bdir/test.sh', '#!/bin/bash\necho test\n',
|
|
mode=0o755)
|
|
self.repo.write_file('bdir/noexec.sh', '#!/bin/bash\necho test\n')
|
|
self.repo.symlink('slink', 'hello')
|
|
self.repo.commit('Initial commit.')
|
|
|
|
@hypothesis.given(testcase.FILENAME_STRATEGY)
|
|
def test_create(self, basename):
|
|
filename = os.path.join(self.mount, basename)
|
|
|
|
# Ensure that we don't proceed if hypothesis has selected a name that
|
|
# conflicts with the names we generated in the repo.
|
|
hypothesis.assume(not os.path.exists(filename))
|
|
|
|
with open(filename, 'w') as f:
|
|
f.write('created\n')
|
|
|
|
entries = sorted(os.listdir(self.mount))
|
|
self.assertEqual(
|
|
sorted(['.eden', 'adir', 'bdir', 'hello', basename, 'slink']),
|
|
entries)
|
|
|
|
with open(filename, 'r') as f:
|
|
self.assertEqual(f.read(), 'created\n')
|
|
|
|
st = os.lstat(filename)
|
|
self.assertEqual(st.st_size, 8)
|
|
self.assertTrue(stat.S_ISREG(st.st_mode))
|