Package com.intellij.openapi.vcs.changes

Examples of com.intellij.openapi.vcs.changes.ContentRevision


        throw new RevuFriendlyException("Failed to parse VCS revision number: " + rev,
          RevuBundle.message("friendlyError.failedToFetchVcsFile.invalidRevision.details.text",
          vFile.getPath(), rev));
      }

      ContentRevision contentRevision = diffProvider.createFileContent(vcsRevisionNumber, vFile);
      String content = null;
      if (contentRevision != null)
      {
        try
        {
          if (LOGGER.isDebugEnabled())
          {
            LOGGER.debug("Fetching from VCS:" + contentRevision);
          }
          content = contentRevision.getContent();
        }
        catch (VcsException e)
        {
          throw new RevuFriendlyException("Error while retrieving VCS content: " + contentRevision,
            null, RevuBundle.message("friendlyError.failedToFetchVcsFile.vcsError.details.text",
            RevuBundle.message("general.vcsFileAndRev.text", vFile.getPath(), rev), e.getMessage()), e);
        }
      }

      if (content == null)
      {
        throw new RevuFriendlyException("VCS fetched content is null: ",
          RevuBundle.message("friendlyError.failedToFetchVcsFile.nullContent.details.text",
          vFile.getPath(), contentRevision));
      }

      return new VcsVirtualFile(contentRevision.getFile().getPath(), content.getBytes(),
        vcsRevisionNumber.asString(), vFile.getFileSystem());
    }
View Full Code Here


        throw new RevuFriendlyException("Failed to parse VCS revision number: " + rev,
          RevuBundle.message("friendlyError.failedToFetchVcsFile.invalidRevision.details.text",
          vFile.getPath(), rev));
      }

      ContentRevision contentRevision = diffProvider.createFileContent(vcsRevisionNumber, vFile);
      String content = null;
      if (contentRevision != null)
      {
        try
        {
          if (LOGGER.isDebugEnabled())
          {
            LOGGER.debug("Fetching from VCS:" + contentRevision);
          }
          content = contentRevision.getContent();
        }
        catch (VcsException e)
        {
          throw new RevuFriendlyException("Error while retrieving VCS content: " + contentRevision,
            null, RevuBundle.message("friendlyError.failedToFetchVcsFile.vcsError.details.text",
            RevuBundle.message("general.vcsFileAndRev.text", vFile.getPath(), rev), e.getMessage()), e);
        }
      }

      if (content == null)
      {
        throw new RevuFriendlyException("VCS fetched content is null: "+ contentRevision,
          RevuBundle.message("friendlyError.failedToFetchVcsFile.nullContent.details.text",
          vFile.getPath()));
      }

      return new VcsVirtualFile(contentRevision.getFile().getPath(), content.getBytes(),
        vcsRevisionNumber.asString(), vFile.getFileSystem());
    }
View Full Code Here

  public static Collection<VirtualFile> getModifiedFilesByList(@NotNull final ChangeList list, final DataContext dataContext) {
    final Collection<VirtualFile> result = new ArrayList<VirtualFile>();
    final Collection<Change> changeCollection = list.getChanges();
    // (Change[]) DataProvider.getData(DataConstants.CHANGES)
    for (final Change change : changeCollection) {
      final ContentRevision contentRevision = change.getAfterRevision();
      if (contentRevision != null) {
        final FilePath path = contentRevision.getFile();
        result.add(path.getVirtualFile());
      }
    }
    return result;
  }
View Full Code Here

    ArrayList<VirtualFile> addedFiles = new ArrayList<VirtualFile>();
        List<VcsException> exceptions = new ArrayList<VcsException>();

    for (Change change : changes) {
      if (FileStatus.MODIFIED.equals(change.getFileStatus())) {
        ContentRevision afterRevision = change.getAfterRevision();
        if (afterRevision != null) {
          FilePath filePath = afterRevision.getFile();
          modifiedFiles.add(VcsUtil.getVirtualFile(filePath.getIOFile()));
        }

      } else if (FileStatus.ADDED.equals(change.getFileStatus())) {
                addedFiles.add(change.getAfterRevision().getFile().getVirtualFile());
View Full Code Here

        ArrayList<VirtualFile> modifiedFiles = new ArrayList<VirtualFile>();
        ArrayList<VirtualFile> addedFiles = new ArrayList<VirtualFile>();
        List<VcsException> exceptions = new ArrayList<VcsException>();
        for (Change change : changes) {
            if (FileStatus.MODIFIED.equals(change.getFileStatus())) {
                ContentRevision afterRevision = change.getAfterRevision();
                if (afterRevision != null) {
                    FilePath filePath = afterRevision.getFile();
                    modifiedFiles.add(VcsUtil.getVirtualFile(filePath.getIOFile()));
                }

            } else if (FileStatus.ADDED.equals(change.getFileStatus())) {
                addedFiles.add(change.getAfterRevision().getFile().getVirtualFile());
            }else {
                exceptions.add(new VcsException("only MODIFIED/ADDED (!= "+change.getFileStatus()+"files are currently supported" ));
            }
        }
        RevertAPICommand revertAPICommand = new RevertAPICommand();
        try {
            List<VirtualFile> filesToRevert = new ArrayList<VirtualFile>();
            filesToRevert.addAll(modifiedFiles);
            filesToRevert.addAll(addedFiles);
            revertAPICommand.executeCommand(mksVcs, exceptions, filesToRevert.toArray(new VirtualFile[filesToRevert.size()]));
        } catch (VcsException e) {
            //noinspection ThrowableInstanceNeverThrown
            exceptions.add(e);
        }
        for (Change change : changes) {
            File beforePath = null;
            logger.debug("MksRollbackEnvironment.rollbackChanges " + change);
            ContentRevision beforeRevision = change.getBeforeRevision();
            if (beforeRevision != null && beforeRevision instanceof MksContentRevision) {
                // file was not created by change
                beforePath = beforeRevision.getFile().getIOFile();
                revert(beforePath, vcsExceptions);
            }
            ContentRevision afterRevision = change.getAfterRevision();
            if (afterRevision != null) {
                File afterPath = afterRevision.getFile().getIOFile();
                if (!afterPath.equals(beforePath)) {
                    // todo file has been renamed !!!
/*
                    UnversionedFilesCollector collector = new UnversionedFilesCollector();
                    try {
View Full Code Here

        } else {
            super.changesMoved(changes, fromList, toList);
        }
        if (isChangeListMksControlled(fromList.getName()) != isChangeListMksControlled(toList.getName())) {
            for (Change change : changes) {
                final ContentRevision afterRevision = change.getAfterRevision();
                final ContentRevision beforeRevision = change.getBeforeRevision();
                if (afterRevision != null) {
                    logger.warn("dirtying file " + afterRevision.getFile());
                    VcsDirtyScopeManager.getInstance(mksVcs.getProject()).fileDirty(afterRevision.getFile());
                }
                if (beforeRevision != null) {
                    logger.warn("dirtying file " + beforeRevision.getFile());
                    VcsDirtyScopeManager.getInstance(mksVcs.getProject()).fileDirty(beforeRevision.getFile());
                }
            }
        }
    }
View Full Code Here

        }
        return null;
    }

    private VirtualFile createVirtualFileForRevision(Revision r) {
        ContentRevision cr = SvnRepositoryContentRevision.create(SvnVcs.getInstance(_project),
                revisionHistory.getRepoRoot(), r.getRelPath(), null, r.getRevisionNumber());
        return ContentRevisionVirtualFile.create(cr);
    }
View Full Code Here

        comments = setupCommentsSupplier();
        drafts = setupDraftsSupplier();
    }

    private String getAffectedFilePath(Change change) {
        ContentRevision afterRevision = change.getAfterRevision();
        if (afterRevision != null) {
            return afterRevision.getFile().getPath();
        }
        ContentRevision beforeRevision = change.getBeforeRevision();
        if (beforeRevision != null) {
            return beforeRevision.getFile().getPath();
        }
        return null;
    }
View Full Code Here

    private void addedFiles() throws VcsException {
        Sets.SetView<String> addedFiles = Sets.difference(changes.keySet(), baseChanges.keySet());
        for (String addedFile : addedFiles) {
            Change change = changes.get(addedFile);
            ContentRevision beforeRevision = null;
            if (change.getType().equals(Change.Type.MODIFICATION)) {
                ContentRevision changeBeforeRevision = change.getBeforeRevision();
                assert changeBeforeRevision != null;
                beforeRevision = new SimpleContentRevision(
                        changeBeforeRevision.getContent(),
                        changeBeforeRevision.getFile(),
                        baseHash);
            }
            diff.add(new Change(beforeRevision, change.getAfterRevision()));
        }
    }
View Full Code Here

    private void changedFiles() {
        Sets.SetView<String> changedFiles = Sets.intersection(baseChanges.keySet(), changes.keySet());
        for (String changedFile : changedFiles) {
            Change baseChange = baseChanges.get(changedFile);
            ContentRevision baseRevision = baseChange.getAfterRevision();
            Change change = changes.get(changedFile);
            ContentRevision revision = change.getAfterRevision();
            if (baseRevision != null || revision != null) {
                diff.add(new Change(baseRevision, revision));
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.intellij.openapi.vcs.changes.ContentRevision

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.