public void buildPatch()

in clearcase-server/src/jetbrains/buildServer/buildTriggers/vcs/clearcase/CCPatchProvider.java [48:112]


  public void buildPatch(final PatchBuilder builder, final Revision fromVersion, final Revision lastVersion)
    throws IOException, VcsException, ExecutionException {
    try {
      if (fromVersion == null) {
        if (CC_OPTIMIZE_CHECKOUT) {
          LOG.warn("Exporting files from disk and ignoring the revision to checkout. Can result in inconsistent checkout on wrong revision. " +
                   "Remove internal property '" + CLEARCASE_OPTIMIZE_INITIAL_CHECKOUT_PROPERTY_NAME + "' to disable this optimization.");
          VcsSupportUtil.exportFilesFromDisk(builder, new File(myConnection.getViewWholePath()));
        }
        else {
          myConnection.processAllVersions(lastVersion, createFileProcessor(builder), false, myUseCCCache);
        }
      }
      else if (!myConnection.isConfigSpecWasChanged()) {
        CCParseUtil.processChangedFiles(myConnection, fromVersion, lastVersion, new ChangedFilesProcessor() {
            public void processChangedFile(@NotNull final HistoryElement element) throws VcsException {
                final String path = element.getObjectName();
                final Version version = myConnection.getLastVersion(path, true);
                final String elementLastVersion = version == null ? null : version.getWholeName();
                if (elementLastVersion != null) {
                    loadFile(path + CCParseUtil.CC_VERSION_SEPARATOR + elementLastVersion, builder, getRelativePath(path));
                }
            }

            public void processChangedDirectory(@NotNull final HistoryElement element) throws IOException, VcsException {
            CCParseUtil.processChangedDirectory(element, myConnection, new ChangedStructureProcessor() {
              public void fileAdded(@NotNull final SimpleDirectoryChildElement simpleChild) throws VcsException {
                final DirectoryChildElement child = simpleChild.createFullElement(myConnection);
                if (child != null) {
                  loadFile(child.getFullPath(), builder, getRelativePath(child.getPath()));
                }
              }

              public void fileDeleted(@NotNull final SimpleDirectoryChildElement simpleChild) throws IOException {
                builder.deleteFile(new File(getRelativePath(simpleChild)), false);
              }

              public void directoryDeleted(@NotNull final SimpleDirectoryChildElement simpleChild) throws IOException {
                builder.deleteDirectory(new File(getRelativePath(simpleChild)), false);
              }

              public void directoryAdded(@NotNull final SimpleDirectoryChildElement simpleChild) throws VcsException, IOException {
                final DirectoryChildElement child = simpleChild.createFullElement(myConnection);
                if (child != null) {
                  builder.createDirectory(new File(getRelativePath(child.getPath())));
                  myConnection.processAllVersions(child.getFullPath(), getRelativePath(child.getPath()),createFileProcessor(builder));
                }
              }
            });
          }

          public void processDestroyedFileVersion(@NotNull final HistoryElement element) throws VcsException {
            processChangedFile(element);
          }
        });
      }
      else {
        myConnection.processAllVersions(lastVersion, createFileProcessor(builder), false, myUseCCCache);
      }
    } finally {
      if (myTempFile != null) {
        FileUtil.delete(myTempFile);
      }
    }
  }