Example #1
0
 private void broadcastRepositoryChange(RepositoryRoot root) {
   if (notificationLevel == 0) {
     broadcastRepositoriesChanged(new ICVSRepositoryLocation[] {root.getRoot()});
   } else {
     changedRepositories.put(root.getRoot().getLocation(false), root.getRoot());
   }
 }
Example #2
0
 /**
  * Accept tags for any CVS resource. However, for the time being, the given version tags are added
  * to the list of known tags for the remote ancestor of the resource that is a direct child of the
  * remote root
  */
 public void addTags(ICVSResource resource, CVSTag[] tags) throws CVSException {
   RepositoryRoot root = getRepositoryRootFor(resource);
   // XXX could be a file or folder
   String remotePath = RepositoryRoot.getRemotePathFor(resource);
   root.addTags(remotePath, tags);
   broadcastRepositoryChange(root);
 }
Example #3
0
  private void readOldState(DataInputStream dis) throws IOException, TeamException {
    int repoSize = dis.readInt();
    boolean version1 = false;
    if (repoSize == STATE_FILE_VERSION_1) {
      version1 = true;
      repoSize = dis.readInt();
    }
    for (int i = 0; i < repoSize; i++) {
      ICVSRepositoryLocation root = KnownRepositories.getInstance().getRepository(dis.readUTF());
      RepositoryRoot repoRoot = getRepositoryRootFor(root);

      // read branch tags associated with this root
      int tagsSize = dis.readInt();
      CVSTag[] branchTags = new CVSTag[tagsSize];
      for (int j = 0; j < tagsSize; j++) {
        String tagName = dis.readUTF();
        int tagType = dis.readInt();
        branchTags[j] = new CVSTag(tagName, tagType);
      }
      // Ignore the branch tags since they are handled differently now
      // addBranchTags(root, branchTags);

      // read the number of projects for this root that have version tags
      int projSize = dis.readInt();
      if (projSize > 0) {
        for (int j = 0; j < projSize; j++) {
          String name = dis.readUTF();
          Set tagSet = new HashSet();
          int numTags = dis.readInt();
          for (int k = 0; k < numTags; k++) {
            tagSet.add(new CVSTag(dis.readUTF(), CVSTag.VERSION));
          }
          CVSTag[] tags = (CVSTag[]) tagSet.toArray(new CVSTag[tagSet.size()]);
          repoRoot.addTags(name, tags);
        }
      }
      // read the auto refresh filenames for this project
      if (version1) {
        try {
          projSize = dis.readInt();
          if (projSize > 0) {
            for (int j = 0; j < projSize; j++) {
              String name = dis.readUTF();
              Set filenames = new HashSet();
              int numFilenames = dis.readInt();
              for (int k = 0; k < numFilenames; k++) {
                filenames.add(name + "/" + dis.readUTF()); // $NON-NLS-1$
              }
              repoRoot.setAutoRefreshFiles(
                  name, (String[]) filenames.toArray(new String[filenames.size()]));
            }
          }
        } catch (EOFException e) {
          // auto refresh files are not persisted, continue and save them next time.
        }
      }
      broadcastRepositoryChange(repoRoot);
    }
  }
Example #4
0
 /*
  * Fetches tags from auto-refresh files if they exist. Then fetches tags from the user defined auto-refresh file
  * list. The fetched tags are cached in the CVS ui plugin's tag cache.
  */
 public CVSTag[] refreshDefinedTags(
     ICVSFolder folder, boolean recurse, boolean notify, IProgressMonitor monitor)
     throws TeamException {
   RepositoryRoot root = getRepositoryRootFor(folder);
   CVSTag[] tags = root.refreshDefinedTags(folder, recurse, monitor);
   if (tags.length > 0 && notify) broadcastRepositoryChange(root);
   return tags;
 }
Example #5
0
 private void writeState(XMLWriter writer) {
   writer.startTag(RepositoriesViewContentHandler.REPOSITORIES_VIEW_TAG, null, true);
   // Write the repositories
   Collection repos = Arrays.asList(getKnownRepositoryLocations());
   Iterator it = repos.iterator();
   while (it.hasNext()) {
     CVSRepositoryLocation location = (CVSRepositoryLocation) it.next();
     RepositoryRoot root = getRepositoryRootFor(location);
     root.writeState(writer);
   }
   writer.endTag(RepositoriesViewContentHandler.REPOSITORIES_VIEW_TAG);
 }
Example #6
0
 /*
  * XXX I hope this methos is not needed in this form
  */
 public Map getKnownProjectsAndVersions(ICVSRepositoryLocation location) {
   Map knownTags = new HashMap();
   RepositoryRoot root = getRepositoryRootFor(location);
   String[] paths = root.getKnownRemotePaths();
   for (int i = 0; i < paths.length; i++) {
     String path = paths[i];
     Set result = new HashSet();
     result.addAll(Arrays.asList(root.getAllKnownTags(path)));
     knownTags.put(path, result);
   }
   return knownTags;
 }
Example #7
0
 /**
  * Method setLabel.
  *
  * @param location
  * @param label
  */
 public void setLabel(CVSRepositoryLocation location, String label) {
   RepositoryRoot root = getRepositoryRootFor(location);
   String oldLabel = root.getName();
   if (oldLabel == null) {
     if (label == null) return;
     root.setName(label);
   } else if (label == null) {
     root.setName(label);
   } else if (label.equals(oldLabel)) {
     return;
   } else {
     root.setName(label);
   }
   broadcastRepositoryChange(root);
 }
Example #8
0
 /** Get the list of known version tags for a given project. */
 public CVSTag[] getKnownTags(ICVSRepositoryLocation location, int tagType) {
   Set result = new HashSet();
   RepositoryRoot root = (RepositoryRoot) repositoryRoots.get(location.getLocation(false));
   if (root != null) {
     String[] paths = root.getKnownRemotePaths();
     for (int i = 0; i < paths.length; i++) {
       String path = paths[i];
       CVSTag[] tags = root.getAllKnownTags(path);
       for (int j = 0; j < tags.length; j++) {
         CVSTag tag = tags[j];
         if (tag.getType() == tagType) result.add(tag);
       }
     }
   }
   return (CVSTag[]) result.toArray(new CVSTag[0]);
 }
Example #9
0
 public ICVSRemoteResource[] getFoldersForTag(
     ICVSRepositoryLocation location, CVSTag tag, IProgressMonitor monitor) throws CVSException {
   monitor = Policy.monitorFor(monitor);
   try {
     monitor.beginTask(
         NLS.bind(
             CVSUIMessages.RepositoryManager_fetchingRemoteFolders, new String[] {tag.getName()}),
         100);
     if (tag.getType() == CVSTag.HEAD) {
       ICVSRemoteResource[] resources =
           location.members(tag, false, Policy.subMonitorFor(monitor, 60));
       RepositoryRoot root = getRepositoryRootFor(location);
       ICVSRemoteResource[] modules =
           root.getDefinedModules(tag, Policy.subMonitorFor(monitor, 40));
       ICVSRemoteResource[] result = new ICVSRemoteResource[resources.length + modules.length];
       System.arraycopy(resources, 0, result, 0, resources.length);
       System.arraycopy(modules, 0, result, resources.length, modules.length);
       return result;
     }
     if (tag.getType() == CVSTag.DATE) {
       ICVSRemoteResource[] resources =
           location.members(tag, false, Policy.subMonitorFor(monitor, 60));
       RepositoryRoot root = getRepositoryRootFor(location);
       ICVSRemoteResource[] modules =
           root.getDefinedModules(tag, Policy.subMonitorFor(monitor, 40));
       ICVSRemoteResource[] result = new ICVSRemoteResource[resources.length + modules.length];
       System.arraycopy(resources, 0, result, 0, resources.length);
       System.arraycopy(modules, 0, result, resources.length, modules.length);
       return result;
     }
     Set result = new HashSet();
     // Get the tags for the location
     RepositoryRoot root = getRepositoryRootFor(location);
     String[] paths = root.getKnownRemotePaths();
     for (int i = 0; i < paths.length; i++) {
       String path = paths[i];
       List tags = Arrays.asList(root.getAllKnownTags(path));
       if (tags.contains(tag)) {
         ICVSRemoteFolder remote =
             root.getRemoteFolder(path, tag, Policy.subMonitorFor(monitor, 100));
         result.add(remote);
       }
     }
     return (ICVSRemoteResource[]) result.toArray(new ICVSRemoteResource[result.size()]);
   } finally {
     monitor.done();
   }
 }
Example #10
0
 /**
  * Add the given repository root to the receiver. The provided instance of RepositoryRoot is used
  * to provide extra information about the repository location
  *
  * @param currentRepositoryRoot
  */
 public void add(RepositoryRoot root) {
   repositoryRoots.put(root.getRoot().getLocation(false), root);
   broadcastRepositoryChange(root);
 }
Example #11
0
 /** Remove the given tags from the list of known tags for the given remote root. */
 public void removeTags(ICVSFolder project, CVSTag[] tags) throws CVSException {
   RepositoryRoot root = getRepositoryRootFor(project);
   String remotePath = RepositoryRoot.getRemotePathFor(project);
   root.removeTags(remotePath, tags);
   broadcastRepositoryChange(root);
 }
Example #12
0
 public String[] getAutoRefreshFiles(ICVSFolder project) throws CVSException {
   RepositoryRoot root = getRepositoryRootFor(project);
   String remotePath = RepositoryRoot.getRemotePathFor(project);
   return root.getAutoRefreshFiles(remotePath);
 }
Example #13
0
 public CVSTag[] getKnownTags(ICVSFolder project) throws CVSException {
   RepositoryRoot root = getRepositoryRootFor(project);
   String remotePath = RepositoryRoot.getRemotePathFor(project);
   return root.getAllKnownTags(remotePath);
 }
Example #14
0
 public void removeDateTag(ICVSRepositoryLocation location, CVSTag tag) {
   RepositoryRoot root = getRepositoryRootFor(location);
   root.removeDateTag(tag);
   broadcastRepositoryChange(root);
 }
Example #15
0
 public CVSTag[] getDateTags(ICVSRepositoryLocation location) {
   RepositoryRoot root = getRepositoryRootFor(location);
   return root.getDateTags();
 }
Example #16
0
 public void addDateTag(ICVSRepositoryLocation location, CVSTag tag) {
   if (tag == null) return;
   RepositoryRoot root = getRepositoryRootFor(location);
   root.addDateTag(tag);
   broadcastRepositoryChange(root);
 }
Example #17
0
 /** Purge any cahced information. */
 public void purgeCache() {
   for (Iterator iter = repositoryRoots.values().iterator(); iter.hasNext(); ) {
     RepositoryRoot root = (RepositoryRoot) iter.next();
     root.clearCache();
   }
 }
Example #18
0
 public void setAutoRefreshFiles(ICVSFolder project, String[] filePaths) throws CVSException {
   RepositoryRoot root = getRepositoryRootFor(project);
   String remotePath = RepositoryRoot.getRemotePathFor(project);
   root.setAutoRefreshFiles(remotePath, filePaths);
 }