Exemplo n.º 1
0
 private void undo(Cell cell) {
   if (!CVS.isDELIB(cell.getLibrary())) return;
   File libraryFile = TextUtils.getFile(cell.getLibrary().getLibFile());
   if (libraryFile == null) return;
   String libfile = libraryFile.getPath();
   // get cell directory if not already added before
   // check cell files
   File cellFile = new File(libfile, DELIB.getCellFile(cell));
   if (undo(cellFile)) {
     State state = CVSLibrary.getState(cell);
     if (state == State.ADDED) CVSLibrary.setState(cell, State.UNKNOWN);
     if (state == State.REMOVED) CVSLibrary.setState(cell, State.NONE);
   }
 }
Exemplo n.º 2
0
 private void undo(Library lib) {
   // see if library file is in CVS
   File libraryFile = TextUtils.getFile(lib.getLibFile());
   if (libraryFile == null) return;
   String libfile = libraryFile.getPath();
   if (!CVS.isDELIB(lib)) {
     if (undo(new File(libfile))) {
       State state = CVSLibrary.getState(lib);
       if (state == State.ADDED) CVSLibrary.setState(lib, State.UNKNOWN);
       if (state == State.REMOVED) CVSLibrary.setState(lib, State.NONE);
     }
   } else {
     for (Iterator<Cell> it = lib.getCells(); it.hasNext(); ) {
       undo(it.next());
     }
     // undo header file
     File headerFile = new File(libfile, DELIB.getHeaderFile());
     undo(headerFile);
   }
 }
Exemplo n.º 3
0
  /**
   * Add or Remove libs and cells from CVS.
   *
   * @param libs
   * @param cells
   * @param add true to add to cvs, false to remove from cvs
   * @param undo true to undo add/remove (boolean add ignored in this case).
   */
  public static void addremove(List<Library> libs, List<Cell> cells, boolean add, boolean undo) {
    if (libs == null) libs = new ArrayList<Library>();
    if (cells == null) cells = new ArrayList<Cell>();

    // make sure cells are part of a DELIB
    CVSLibrary.LibsCells bad = CVSLibrary.notFromDELIB(cells);
    if (bad.cells.size() > 0) {
      CVS.showError(
          "Error: the following Cells are not part of a DELIB library and cannot be acted upon individually",
          "CVS Add/Remove Error",
          bad.libs,
          bad.cells);
      return;
    }
    bad = CVSLibrary.getModified(libs, cells);
    if (bad.libs.size() > 0 || bad.cells.size() > 0) {
      CVS.showError(
          "Error: the following Libraries or Cells must be saved first",
          "CVS " + (add ? "Add" : "Remove") + " Error",
          bad.libs,
          bad.cells);
      return;
    }

    // delib cells must have library added first
    List<Library> assertLibsInCVS = new ArrayList<Library>();
    for (Cell cell : cells) {
      Library lib = cell.getLibrary();
      if (libs.contains(lib) || assertLibsInCVS.contains(lib)) continue;
      assertLibsInCVS.add(lib);
    }
    bad = CVSLibrary.getNotInCVS(assertLibsInCVS, null);
    if (bad.libs.size() > 0) {
      CVS.showError(
          "Error: cannot add DELIB cells if cell's DELIB library is not in cvs",
          "CVS " + (add ? "Add" : "Remove") + " Error",
          bad.libs,
          bad.cells);
      return;
    }

    // optimize a little, remove cells from cells list if cell's lib in libs list
    CVSLibrary.LibsCells good = CVSLibrary.consolidate(libs, cells);

    if (!undo) {
      // when job generates files to add/remove, it will do the check to see if they are in
      // cvs or not. Don't do it here because we may specify lib to add unadded cells.
      /*
                  if (add) {
                      good = CVSLibrary.getNotInCVS(libs, cells);
                  } else {
                      good = CVSLibrary.getInCVS(libs, cells);
                  }
      */
      // issue final warning for Remove
      if (!add) {
        StringBuffer list =
            new StringBuffer(
                "Warning! CVS Remove will delete disk files for these Libraries and Cells!!!");
        for (Library lib : good.libs) list.append("\n  " + lib.getName());
        for (Cell cell : good.cells) list.append("\n  " + cell.libDescribe());
        if (!Job.getUserInterface().confirmMessage(list.toString())) return;
      }

      (new AddRemoveJob(good.libs, good.cells, add)).startJob();
    } else {
      (new UndoAddRemoveJob(good.libs, good.cells)).startJob();
    }
  }
Exemplo n.º 4
0
    public boolean doIt() {
      String useDir = CVS.getUseDir(libs, cells);

      List<Library> stateChangeLibs = new ArrayList<Library>();
      List<Cell> stateChangeCells = new ArrayList<Cell>();
      // mark files as added/removed
      for (Library lib : libs) {
        if (CVS.isDELIB(lib)) {
          for (Iterator<Cell> it = lib.getCells(); it.hasNext(); ) {
            Cell cell = it.next();
            if (add) {
              if (!CVS.isFileInCVS(CVS.getCellFile(cell))) stateChangeCells.add(cell);
            } else {
              if (CVS.isFileInCVS(CVS.getCellFile(cell))) stateChangeCells.add(cell);
            }
          }
        } else {
          // jelib or elib file
          if (add) {
            // if lib.getLibFile() is null -> library hasn't been saved
            URL fileURL = lib.getLibFile();
            if (fileURL == null) {
              System.out.println("Library not on disk yet. Save it before applying this command");
              exitVal = 0;
              return true;
            }
            if (!CVS.isFileInCVS(new File(fileURL.getPath()))) stateChangeLibs.add(lib);
          } else {
            if (!CVS.isFileInCVS(new File(lib.getLibFile().getPath()))) stateChangeLibs.add(lib);
          }
        }
      }
      for (Cell cell : cells) {
        if (add) {
          if (!CVS.isFileInCVS(CVS.getCellFile(cell))) stateChangeCells.add(cell);
        } else {
          if (CVS.isFileInCVS(CVS.getCellFile(cell))) stateChangeCells.add(cell);
        }
      }

      // unfortunately add/remove are not recursive, so we have
      // to specify directories as well as files to add/remove
      StringBuffer buf = new StringBuffer();
      for (Library lib : libs) {
        generate(buf, lib, useDir);
      }
      for (Cell cell : cells) {
        generate(buf, cell, useDir);
      }

      String addRemoveFiles = buf.toString();
      if (addRemoveFiles.trim().equals("")) {
        System.out.println("Nothing to " + (add ? "Add" : "Remove"));
        exitVal = 0;
        return true;
      }
      String command = add ? "add" : "remove -f";
      String message = "Running CVS " + (add ? "Add" : "Remove");
      exitVal =
          CVS.runCVSCommand(
              cvsProgram,
              repository,
              "-q " + command + " " + addRemoveFiles,
              message,
              useDir,
              System.out);
      fieldVariableChanged("exitVal");
      if (exitVal != 0) return true;

      System.out.println("CVS " + command + " complete");
      for (Cell cell : stateChangeCells) {
        if (add) CVSLibrary.setState(cell, State.ADDED);
        else CVSLibrary.setState(cell, State.REMOVED);
      }
      for (Library lib : stateChangeLibs) {
        if (add) CVSLibrary.setState(lib, State.ADDED);
        else CVSLibrary.setState(lib, State.REMOVED);
      }

      return true;
    }