Ejemplo n.º 1
0
  /**
   * Create or update the administration files for a particular file. This will create the CVS
   * directory if necessary, and the Root and Repository files if necessary. It will also update the
   * Entries file with the new entry
   *
   * @param localDirectory the local directory, relative to the directory in which the command was
   *     given, where the file in question lives
   * @param repositoryPath the path of the file in the repository, in absolute form.
   * @param entry the entry object for that file
   */
  public void updateAdminData(String localDirectory, String repositoryPath, Entry entry)
      throws IOException {
    final String absolutePath = localPath + '/' + localDirectory;
    if (repositoryPath.startsWith(getRepository())) {
      repositoryPath = repositoryPath.substring(getRepository().length() + 1);
    } else {
      if (warned == false) {
        String warning =
            "#65188 warning C/S protocol error (section 5.10). It's regurarly observed with cvs 1.12.xx servers.\n"; // NOI18N
        warning +=
            "  unexpected pathname="
                + repositoryPath
                + " missing root prefix="
                + getRepository()
                + "\n"; // NOI18N
        warning += "  relaxing, but who knows all consequences...."; // NOI18N
        System.err.println(warning);
        warned = true;
      }
    }

    adminHandler.updateAdminData(absolutePath, repositoryPath, entry, globalOptions);
  }
Ejemplo n.º 2
0
  /**
   * 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;
    }
  }
Ejemplo n.º 3
0
 /**
  * Checks for presence of CVS/Tag file and returns it's value.
  *
  * @return the value of CVS/Tag file for the specified directory null if file doesn't exist
  */
 public String getStickyTagForDirectory(File directory) {
   return adminHandler.getStickyTagForDirectory(directory);
 }
Ejemplo n.º 4
0
 /**
  * Get all the files contained within a given directory that are <b>known to CVS</b>.
  *
  * @param directory the directory to look in
  * @return a set of all files.
  */
 public Set getAllFiles(File directory) throws IOException {
   return adminHandler.getAllFiles(directory);
 }
Ejemplo n.º 5
0
 /**
  * Remove the Entry for the specified file.
  *
  * @param file the file whose entry is to be removed
  * @throws IOException if an error occurs writing the Entries file
  */
 public void removeEntry(File file) throws IOException {
   adminHandler.removeEntry(file);
 }
Ejemplo n.º 6
0
 /**
  * Set the Entry for the specified file.
  *
  * @param file the file
  * @param entry the new entry
  * @throws IOException if an error occurs writing the details
  */
 public void setEntry(File file, Entry entry) throws IOException {
   adminHandler.setEntry(file, entry);
 }
Ejemplo n.º 7
0
 public String getRepositoryForDirectory(File directory) throws IOException {
   return adminHandler.getRepositoryForDirectory(directory.getAbsolutePath(), getRepository());
 }
Ejemplo n.º 8
0
 public boolean exists(File file) {
   return adminHandler.exists(file);
 }
Ejemplo n.º 9
0
 /**
  * Get the entries for a specified directory.
  *
  * @param directory the directory for which to get the entries
  * @return an iterator of Entry objects
  */
 public Iterator getEntries(File directory) throws IOException {
   return adminHandler.getEntries(directory);
 }
Ejemplo n.º 10
0
 /**
  * Get the Entry for the specified file, if one exists.
  *
  * @param f the file
  * @throws IOException if the Entries file cannot be read
  */
 public Entry getEntry(File f) throws IOException {
   return adminHandler.getEntry(f);
 }