Exemplo n.º 1
0
  /** Get the list of known branch tags for a given remote root. */
  public CVSTag[] getKnownTags(ICVSFolder project, int tagType) {
    try {
      CVSTag[] tags = getKnownTags(project);
      Set result = new HashSet();
      for (int i = 0; i < tags.length; i++) {
        CVSTag tag = tags[i];
        if (tag.getType() == tagType) result.add(tag);
      }

      return (CVSTag[]) result.toArray(new CVSTag[result.size()]);
    } catch (CVSException e) {
      CVSUIPlugin.log(e);
      return new CVSTag[0];
    }
  }
Exemplo n.º 2
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();
   }
 }
Exemplo n.º 3
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]);
 }
  /**
   * Given the current selection this method returns a text label that can be shown to the user that
   * reflects the tags in the current selection. These can be used in the <b>Compare With</b> and
   * <b>Replace With</b> actions.
   */
  protected String calculateActionTagValue() {
    try {
      IResource[] resources = getSelectedResources();
      CVSTag commonTag = null;
      boolean sameTagType = true;
      boolean multipleSameNames = true;

      for (int i = 0; i < resources.length; i++) {
        ICVSResource cvsResource = getCVSResourceFor(resources[i]);
        CVSTag tag = null;
        if (cvsResource.isFolder()) {
          FolderSyncInfo info = ((ICVSFolder) cvsResource).getFolderSyncInfo();
          if (info != null) {
            tag = info.getTag();
          }
          if (tag != null && tag.getType() == CVSTag.BRANCH) {
            tag = Util.getAccurateFolderTag(resources[i], tag);
          }
        } else {
          tag = Util.getAccurateFileTag(cvsResource);
        }
        if (tag == null) {
          tag = new CVSTag();
        }
        if (commonTag == null) {
          commonTag = tag;
        } else if (!commonTag.equals(tag)) {
          if (commonTag.getType() != tag.getType()) {
            sameTagType = false;
          }
          if (!commonTag.getName().equals(tag.getName())) {
            multipleSameNames = false;
          }
        }
      }

      // set text to default
      String actionText = CVSUIMessages.ReplaceWithLatestAction_multipleTags;
      if (commonTag != null) {
        int tagType = commonTag.getType();
        String tagName = commonTag.getName();
        // multiple tag names but of the same type
        if (sameTagType && !multipleSameNames) {
          if (tagType == CVSTag.BRANCH) {
            actionText = CVSUIMessages.ReplaceWithLatestAction_multipleBranches; //
          } else {
            actionText = CVSUIMessages.ReplaceWithLatestAction_multipleVersions;
          }
          // same tag names and types
        } else if (sameTagType && multipleSameNames) {
          if (tagType == CVSTag.BRANCH) {
            actionText =
                NLS.bind(
                    CVSUIMessages.ReplaceWithLatestAction_singleBranch, new String[] {tagName}); //
          } else if (tagType == CVSTag.VERSION) {
            actionText =
                NLS.bind(
                    CVSUIMessages.ReplaceWithLatestAction_singleVersion, new String[] {tagName});
          } else if (tagType == CVSTag.HEAD) {
            actionText =
                NLS.bind(CVSUIMessages.ReplaceWithLatestAction_singleHEAD, new String[] {tagName});
          }
        }
      }

      return actionText;
    } catch (CVSException e) {
      // silently ignore
      return CVSUIMessages.ReplaceWithLatestAction_multipleTags; //
    }
  }