# Path: peru/cache.py
# TEXT_MODE = object()
# BINARY_MODE = object()
# DEBUG_GIT_COMMAND_COUNT = 0
#     LINES_TO_SHOW = 10
# BLOB_TYPE = 'blob'
# TREE_TYPE = 'tree'
# NONEXECUTABLE_FILE_MODE = '100644'
# EXECUTABLE_FILE_MODE = '100755'
# TREE_MODE = '040000'
# DOTPERU_CAPITALIZATIONS = [
#     '.peru',
#     '.Peru',
#     '.pEru',
#     '.peRu',
#     '.perU',
#     '.PEru',
#     '.PeRu',
#     '.PerU',
#     '.pERu',
#     '.pErU',
#     '.peRU',
#     '.PERu',
#     '.PErU',
#     '.PeRU',
#     '.pERU',
#     '.PERU',
# ]
# def compute_key(data):
#     def __init__(self, git_dir, index_file, working_copy):
#     async def git(self, *args, input=None, output_mode=TEXT_MODE, cwd=None):
#     def git_env(self):
#     async def init_git_dir(self):
#     async def read_tree_into_index(self, tree):
#     async def read_tree_and_stats_into_index(self, tree):
#     async def make_tree_from_index(self):
#     async def read_working_copy_into_index(self, picks):
#     async def drop_paths_from_index(self, paths):
#     async def merge_tree_into_index(self, tree, prefix):
#     async def working_copy_matches_index(self):
#     async def get_modified_files_skipping_deletes(self):
#     async def get_new_files_in_tree(self, previous_tree, new_tree):
#     async def read_tree_updating_working_copy(self, tree, force):
#     async def checkout_files_from_index(self):
#     async def get_info_for_path(self, tree, path):
#     async def read_bytes_from_file_hash(self, sha1):
#     async def list_tree_entries(self, tree, path, recursive):
#     async def make_tree_from_entries(self, entries):
# async def Cache(root):
#     def __init__(self, root):
#     async def _init_trees(self):
#     def clean_git_session(self, working_copy=None):
#     def no_index_git_session(self):
#     async def get_empty_tree(self):
#     async def import_tree(self, src, *, picks=None, excludes=None):
#     async def merge_trees(self, base_tree, merge_tree, merge_path='.'):
#     async def export_tree(self,
#                           tree,
#                           dest,
#                           previous_tree=None,
#                           *,
#                           force=False,
#                           previous_index_file=None):
#     async def read_file(self, tree, path):
#     async def ls_tree(self, tree, path=None, *, recursive=False):
#     async def modify_tree(self, tree, modifications):
# def delete_if_error(path):
# def _format_file_lines(files):
#     def __init__(self, command, errorcode, stdout, stderr):
# def dotperu_exclude_case_insensitive_git_globs():
# class GitSession:
# class _Cache:
# class GitError(Exception):
# class ModifyTreeError(PrintableError):
# class DirtyWorkingCopyError(PrintableError):
# class MergeConflictError(PrintableError):
# 
# Path: peru/rule.py
# class Rule:
# class NoMatchingFilesError(PrintableError):
#     def __init__(self, name, copy, move, executable, drop, pick, export):
#     def _cache_key(self, input_tree):
#     async def get_tree(self, runtime, input_tree):
# async def _copy_files_modifications(_cache, tree, paths_multimap):
# async def copy_files(_cache, tree, paths_multimap):
# async def move_files(_cache, tree, paths_multimap):
# async def _get_glob_entries(_cache, tree, globs_list):
# async def pick_files(_cache, tree, globs_list):
# async def drop_files(_cache, tree, globs_list):
# async def make_files_executable(_cache, tree, globs_list):
# async def get_export_tree(_cache, tree, export_path):


import os
import shared
from peru import cache
from peru import rule
from shared import COLON




class RuleTest(shared.PeruTest):
    @shared.make_synchronous
    async def setUp(self):
        self.cache_dir = shared.create_dir()
        self.cache = await cache.Cache(self.cache_dir)
        # Include a leading colon to test that we prepend ./ to pathspecs.
        self.content = {'a': 'foo', 'b/c': 'bar', COLON + 'd': 'baz'}
        self.content_dir = shared.create_dir(self.content)
        self.content_tree = await self.cache.import_tree(self.content_dir)
        self.entries = await self.cache.ls_tree(
            self.content_tree, recursive=True)

    @shared.make_synchronous
    async def test_copy(self):
        # A file copied into a directory should be placed into that directory.
        # A directory or file copied into a file should overwrite that file.
        copies = {'a': ['x', 'b', 'b/c'], 'b': ['a', 'y']}

# Path: peru/cache.py
# TEXT_MODE = object()
# BINARY_MODE = object()
# DEBUG_GIT_COMMAND_COUNT = 0
#     LINES_TO_SHOW = 10
# BLOB_TYPE = 'blob'
# TREE_TYPE = 'tree'
# NONEXECUTABLE_FILE_MODE = '100644'
# EXECUTABLE_FILE_MODE = '100755'
# TREE_MODE = '040000'
# DOTPERU_CAPITALIZATIONS = [
#     '.peru',
#     '.Peru',
#     '.pEru',
#     '.peRu',
#     '.perU',
#     '.PEru',
#     '.PeRu',
#     '.PerU',
#     '.pERu',
#     '.pErU',
#     '.peRU',
#     '.PERu',
#     '.PErU',
#     '.PeRU',
#     '.pERU',
#     '.PERU',
# ]
# def compute_key(data):
#     def __init__(self, git_dir, index_file, working_copy):
#     async def git(self, *args, input=None, output_mode=TEXT_MODE, cwd=None):
#     def git_env(self):
#     async def init_git_dir(self):
#     async def read_tree_into_index(self, tree):
#     async def read_tree_and_stats_into_index(self, tree):
#     async def make_tree_from_index(self):
#     async def read_working_copy_into_index(self, picks):
#     async def drop_paths_from_index(self, paths):
#     async def merge_tree_into_index(self, tree, prefix):
#     async def working_copy_matches_index(self):
#     async def get_modified_files_skipping_deletes(self):
#     async def get_new_files_in_tree(self, previous_tree, new_tree):
#     async def read_tree_updating_working_copy(self, tree, force):
#     async def checkout_files_from_index(self):
#     async def get_info_for_path(self, tree, path):
#     async def read_bytes_from_file_hash(self, sha1):
#     async def list_tree_entries(self, tree, path, recursive):
#     async def make_tree_from_entries(self, entries):
# async def Cache(root):
#     def __init__(self, root):
#     async def _init_trees(self):
#     def clean_git_session(self, working_copy=None):
#     def no_index_git_session(self):
#     async def get_empty_tree(self):
#     async def import_tree(self, src, *, picks=None, excludes=None):
#     async def merge_trees(self, base_tree, merge_tree, merge_path='.'):
#     async def export_tree(self,
#                           tree,
#                           dest,
#                           previous_tree=None,
#                           *,
#                           force=False,
#                           previous_index_file=None):
#     async def read_file(self, tree, path):
#     async def ls_tree(self, tree, path=None, *, recursive=False):
#     async def modify_tree(self, tree, modifications):
# def delete_if_error(path):
# def _format_file_lines(files):
#     def __init__(self, command, errorcode, stdout, stderr):
# def dotperu_exclude_case_insensitive_git_globs():
# class GitSession:
# class _Cache:
# class GitError(Exception):
# class ModifyTreeError(PrintableError):
# class DirtyWorkingCopyError(PrintableError):
# class MergeConflictError(PrintableError):
# 
# Path: peru/rule.py
# class Rule:
# class NoMatchingFilesError(PrintableError):
#     def __init__(self, name, copy, move, executable, drop, pick, export):
#     def _cache_key(self, input_tree):
#     async def get_tree(self, runtime, input_tree):
# async def _copy_files_modifications(_cache, tree, paths_multimap):
# async def copy_files(_cache, tree, paths_multimap):
# async def move_files(_cache, tree, paths_multimap):
# async def _get_glob_entries(_cache, tree, globs_list):
# async def pick_files(_cache, tree, globs_list):
# async def drop_files(_cache, tree, globs_list):
# async def make_files_executable(_cache, tree, globs_list):
# async def get_export_tree(_cache, tree, export_path):


# Path: tests/test_rule.py
import os
import shared
from peru import cache
from peru import rule
from shared import COLON





class RuleTest(shared.PeruTest):
    @shared.make_synchronous
    async def setUp(self):
        self.cache_dir = shared.create_dir()
        self.cache = await cache.Cache(self.cache_dir)
        # Include a leading colon to test that we prepend ./ to pathspecs.
        self.content = {'a': 'foo', 'b/c': 'bar', COLON + 'd': 'baz'}
        self.content_dir = shared.create_dir(self.content)
        self.content_tree = await self.cache.import_tree(self.content_dir)
        self.entries = await self.cache.ls_tree(
            self.content_tree, recursive=True)

    @shared.make_synchronous
    async def test_copy(self):
        # A file copied into a directory should be placed into that directory.
        # A directory or file copied into a file should overwrite that file.
        copies = {'a': ['x', 'b', 'b/c'], 'b': ['a', 'y']}

        tree = await rule.copy_files(self.cache, self.content_tree, copies)