public String getRepositoryForDirectory(final String directory, final String repository) throws IOException {
        // if there is no "CVS/Repository" file, try to search up the file-
        // hierarchy
        File repositoryFile = null;
        String repositoryDirs = ""; // NOI18N
        File dirFile = new File(directory);
        while (true) {
            // if there is no Repository file we cannot very well get any
            // repository from it
            if ((dirFile == null) || (dirFile.getName().length() == 0) || !dirFile.exists()) {
                throw new FileNotFoundException("Repository file not found " + // NOI18N
                                "for directory " + directory); // NOI18N
            }

            repositoryFile = new File(dirFile, "CVS/Repository"); // NOI18N
            if (repositoryFile.exists()) {
                break;
            }
            repositoryDirs = '/' + dirFile.getName() + repositoryDirs;
            dirFile = dirFile.getParentFile();
        }
        BufferedReader reader = null;
        // fileRepository is the value of the repository read from the
        // Repository file
        String fileRepository = null;
        try {
            reader = new BufferedReader(new FileReader(repositoryFile));
            fileRepository = reader.readLine();
        } finally {
            if (reader != null) {
                reader.close();
            }
        }

        if (fileRepository == null) {
            fileRepository = ""; // NOI18N
        }

        fileRepository += repositoryDirs;
        // absolute repository path ?
        if (fileRepository.startsWith("/")) { // NOI18N
            return fileRepository;
        }

        // #69795 'normalize' repository path
        if (fileRepository.startsWith("./")) { // NOI18N
            fileRepository = fileRepository.substring(2);
        }
        // otherwise the cvs is using relative repository path
        // must be a forward slash, regardless of the local filing system
        return repository + '/' + fileRepository;
    }