/** * Get the repository path for a given directory, for example in the directory * /home/project/foo/bar, the repository directory might be /usr/cvs/foo/bar. The repository * directory is commonly stored in the file * * <pre>Repository</pre> * * in the CVS directory on the client (this is the case in the standard CVS command-line tool). * * <p>If no * * <pre>CVS/Repository</pre> * * file was found, the specified directory, the localpath are used to "guess" the repository path. * * @param directory the directory */ public String getRepositoryForDirectory(String directory) throws IOException { try { String repository = adminHandler.getRepositoryForDirectory(directory, getRepository()); return repository; } catch (IOException ex) { // an IOException is thrown, if the adminHandler can't detect the repository // by reading the CVS/Repository file, e.g. when checking out into a new directory try { directory = new File(directory).getCanonicalPath(); } catch (IOException ioex) { } directory = directory.replace('\\', '/'); while (directory.endsWith("/")) { // NOI18N directory = directory.substring(0, directory.length() - 1); } // must also canonicalize 'localPath' to be in sync with 'directory' String localPathCanonical = getLocalPath(); try { localPathCanonical = new File(getLocalPath()).getCanonicalPath(); } catch (IOException ioex) { } localPathCanonical = localPathCanonical.replace('\\', '/'); while (localPathCanonical.endsWith("/")) { // NOI18N localPathCanonical = localPathCanonical.substring(0, localPathCanonical.length() - 1); } int localPathLength = localPathCanonical.length(); String repository; if (directory.length() >= localPathLength) { repository = getRepository() + directory.substring(localPathLength); } else { // Asking for some folder upon the local working path repository = getRepository(); } return repository; } }
public String getRepositoryForDirectory(File directory) throws IOException { return adminHandler.getRepositoryForDirectory(directory.getAbsolutePath(), getRepository()); }