Search in sources :

Example 36 with VcsRevisionNumber

use of com.intellij.openapi.vcs.history.VcsRevisionNumber in project intellij-community by JetBrains.

the class CvsChangeProvider method processFile.

private void processFile(final FilePath filePath, final ChangelistBuilder builder, final ProgressIndicator progress) throws VcsException {
    final VirtualFile dir = filePath.getVirtualFileParent();
    if (dir == null)
        return;
    final Entry entry = myEntriesManager.getEntryFor(dir, filePath.getName());
    final FileStatus status = CvsStatusProvider.getStatus(filePath.getVirtualFile(), entry);
    final VcsRevisionNumber number = entry != null ? createRevisionNumber(entry.getRevision(), status) : VcsRevisionNumber.NULL;
    processStatus(filePath, dir.findChild(filePath.getName()), status, number, builder);
    progress.checkCanceled();
    checkSwitchedFile(filePath, builder, dir, entry);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VirtualFileEntry(com.intellij.cvsSupport2.checkinProject.VirtualFileEntry) Entry(org.netbeans.lib.cvsclient.admin.Entry) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber)

Example 37 with VcsRevisionNumber

use of com.intellij.openapi.vcs.history.VcsRevisionNumber in project intellij-community by JetBrains.

the class FileGroup method getFilesAndRevisions.

public List<Pair<String, VcsRevisionNumber>> getFilesAndRevisions(ProjectLevelVcsManager vcsManager) {
    ArrayList<Pair<String, VcsRevisionNumber>> files = new ArrayList<>();
    for (UpdatedFile file : myFiles) {
        VcsRevisionNumber number = getRevision(vcsManager, file);
        files.add(Pair.create(file.getPath(), number));
    }
    return files;
}
Also used : VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber)

Example 38 with VcsRevisionNumber

use of com.intellij.openapi.vcs.history.VcsRevisionNumber in project intellij-community by JetBrains.

the class MergeUtil method putRevisionInfo.

private static void putRevisionInfo(@NotNull List<? extends DiffContent> contents, @NotNull MergeData data) {
    for (ThreeSide side : ThreeSide.values()) {
        DiffContent content = side.select(contents);
        FilePath filePath = side.select(data.CURRENT_FILE_PATH, data.ORIGINAL_FILE_PATH, data.LAST_FILE_PATH);
        VcsRevisionNumber revision = side.select(data.CURRENT_REVISION_NUMBER, data.ORIGINAL_REVISION_NUMBER, data.LAST_REVISION_NUMBER);
        if (filePath != null && revision != null) {
            content.putUserData(DiffUserDataKeysEx.REVISION_INFO, Pair.create(filePath, revision));
        }
    }
}
Also used : ThreeSide(com.intellij.diff.util.ThreeSide) FilePath(com.intellij.openapi.vcs.FilePath) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) DiffContent(com.intellij.diff.contents.DiffContent)

Example 39 with VcsRevisionNumber

use of com.intellij.openapi.vcs.history.VcsRevisionNumber in project intellij-community by JetBrains.

the class GitNewChangesCollector method parseOutput.

/**
   * Parses the output of the 'git status --porcelain -z' command filling myChanges and myUnversionedFiles.
   * See <a href=http://www.kernel.org/pub/software/scm/git/docs/git-status.html#_output">Git man</a> for details.
   */
// handler is here for debugging purposes in the case of parse error
private void parseOutput(@NotNull String output, @NotNull GitHandler handler) throws VcsException {
    VcsRevisionNumber head = getHead();
    final String[] split = output.split("");
    for (int pos = 0; pos < split.length; pos++) {
        String line = split[pos];
        if (StringUtil.isEmptyOrSpaces(line)) {
            // skip empty lines if any (e.g. the whole output may be empty on a clean working tree).
            continue;
        }
        // format: XY_filename where _ stands for space.
        if (line.length() < 4) {
            // X, Y, space and at least one symbol for the file
            throwGFE("Line is too short.", handler, output, line, '0', '0');
        }
        final String xyStatus = line.substring(0, 2);
        // skipping the space
        final String filepath = line.substring(3);
        final char xStatus = xyStatus.charAt(0);
        final char yStatus = xyStatus.charAt(1);
        switch(xStatus) {
            case ' ':
                if (yStatus == 'M') {
                    reportModified(filepath, head);
                } else if (yStatus == 'D') {
                    reportDeleted(filepath, head);
                } else if (yStatus == 'T') {
                    reportTypeChanged(filepath, head);
                } else if (yStatus == 'U') {
                    reportConflict(filepath, head);
                } else {
                    throwYStatus(output, handler, line, xStatus, yStatus);
                }
                break;
            case 'M':
                if (yStatus == ' ' || yStatus == 'M' || yStatus == 'T') {
                    reportModified(filepath, head);
                } else if (yStatus == 'D') {
                    reportDeleted(filepath, head);
                } else {
                    throwYStatus(output, handler, line, xStatus, yStatus);
                }
                break;
            case 'C':
                //noinspection AssignmentToForLoopParameter
                // read the "from" filepath which is separated also by NUL character.
                pos += 1;
            // we treat "Copy" as "Added", but we still have to read the old path not to break the format parsing.
            case 'A':
                if (yStatus == 'M' || yStatus == ' ' || yStatus == 'T') {
                    reportAdded(filepath);
                } else if (yStatus == 'D') {
                // added + deleted => no change (from IDEA point of view).
                } else if (yStatus == 'U' || yStatus == 'A') {
                    // AU - unmerged, added by us; AA - unmerged, both added
                    reportConflict(filepath, head);
                } else {
                    throwYStatus(output, handler, line, xStatus, yStatus);
                }
                break;
            case 'D':
                if (yStatus == 'M' || yStatus == ' ' || yStatus == 'T') {
                    reportDeleted(filepath, head);
                } else if (yStatus == 'U') {
                    // DU - unmerged, deleted by us
                    reportConflict(filepath, head);
                } else if (yStatus == 'D') {
                // DD - unmerged, both deleted
                // TODO
                // currently not displaying, because "both deleted" conflicts can't be handled by our conflict resolver.
                // see IDEA-63156
                } else {
                    throwYStatus(output, handler, line, xStatus, yStatus);
                }
                break;
            case 'U':
                if (yStatus == 'U' || yStatus == 'A' || yStatus == 'D' || yStatus == 'T') {
                    // UU - unmerged, both modified; UD - unmerged, deleted by them; UA - unmerged, added by them
                    reportConflict(filepath, head);
                } else {
                    throwYStatus(output, handler, line, xStatus, yStatus);
                }
                break;
            case 'R':
                //noinspection AssignmentToForLoopParameter
                // read the "from" filepath which is separated also by NUL character.
                pos += 1;
                String oldFilename = split[pos];
                if (yStatus == 'D') {
                    reportDeleted(filepath, head);
                } else if (yStatus == ' ' || yStatus == 'M' || yStatus == 'T') {
                    reportRename(filepath, oldFilename, head);
                } else {
                    throwYStatus(output, handler, line, xStatus, yStatus);
                }
                break;
            case //TODO
            'T':
                if (yStatus == ' ' || yStatus == 'M') {
                    reportTypeChanged(filepath, head);
                } else if (yStatus == 'D') {
                    reportDeleted(filepath, head);
                } else {
                    throwYStatus(output, handler, line, xStatus, yStatus);
                }
                break;
            case '?':
                throwGFE("Unexpected unversioned file flag.", handler, output, line, xStatus, yStatus);
                break;
            case '!':
                throwGFE("Unexpected ignored file flag.", handler, output, line, xStatus, yStatus);
            default:
                throwGFE("Unexpected symbol as xStatus.", handler, output, line, xStatus, yStatus);
        }
    }
}
Also used : VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber)

Example 40 with VcsRevisionNumber

use of com.intellij.openapi.vcs.history.VcsRevisionNumber in project intellij-community by JetBrains.

the class SvnDiffProvider method getRevision.

@Nullable
private static VcsRevisionNumber getRevision(@Nullable Info info) {
    VcsRevisionNumber result = null;
    if (info != null) {
        SVNRevision revision = SVNRevision.UNDEFINED.equals(info.getCommittedRevision()) && info.getCopyFromRevision() != null ? info.getCopyFromRevision() : info.getRevision();
        result = new SvnRevisionNumber(revision);
    }
    return result;
}
Also used : VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

VcsRevisionNumber (com.intellij.openapi.vcs.history.VcsRevisionNumber)48 VirtualFile (com.intellij.openapi.vfs.VirtualFile)14 Nullable (org.jetbrains.annotations.Nullable)12 NotNull (org.jetbrains.annotations.NotNull)11 VcsFileRevision (com.intellij.openapi.vcs.history.VcsFileRevision)7 FilePath (com.intellij.openapi.vcs.FilePath)6 Project (com.intellij.openapi.project.Project)5 VcsException (com.intellij.openapi.vcs.VcsException)4 File (java.io.File)4 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)3 Pair (com.intellij.openapi.util.Pair)3 AbstractVcs (com.intellij.openapi.vcs.AbstractVcs)3 VcsRoot (com.intellij.openapi.vcs.VcsRoot)3 Change (com.intellij.openapi.vcs.changes.Change)3 VcsVirtualFile (com.intellij.openapi.vcs.vfs.VcsVirtualFile)3 HashMap (com.intellij.util.containers.HashMap)3 DiffContent (com.intellij.diff.contents.DiffContent)2 Logger (com.intellij.openapi.diagnostic.Logger)2 Document (com.intellij.openapi.editor.Document)2 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2