コード例 #1
0
 private void loadState() {
   IPath pluginStateLocation =
       CVSUIPlugin.getPlugin().getStateLocation().append(REPOSITORIES_VIEW_FILE);
   File file = pluginStateLocation.toFile();
   if (file.exists()) {
     try {
       BufferedInputStream is = new BufferedInputStream(new FileInputStream(file));
       try {
         readState(is);
       } finally {
         is.close();
       }
     } catch (IOException e) {
       CVSUIPlugin.log(IStatus.ERROR, CVSUIMessages.RepositoryManager_ioException, e);
     } catch (TeamException e) {
       CVSUIPlugin.log(e);
     }
   } else {
     IPath oldPluginStateLocation = CVSUIPlugin.getPlugin().getStateLocation().append(STATE_FILE);
     file = oldPluginStateLocation.toFile();
     if (file.exists()) {
       try {
         DataInputStream dis = new DataInputStream(new FileInputStream(file));
         try {
           readOldState(dis);
         } finally {
           dis.close();
         }
         saveState();
         file.delete();
       } catch (IOException e) {
         CVSUIPlugin.log(IStatus.ERROR, CVSUIMessages.RepositoryManager_ioException, e);
       } catch (TeamException e) {
         CVSUIPlugin.log(e);
       }
     }
   }
 }
コード例 #2
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);
    }
  }