Search in sources :

Example 6 with VcsFullCommitDetails

use of com.intellij.vcs.log.VcsFullCommitDetails in project intellij-community by JetBrains.

the class GitHistoryUtilsTest method testLoadingDetailsWithU0001Character.

@Test
public void testLoadingDetailsWithU0001Character() throws Exception {
    List<VcsFullCommitDetails> details = ContainerUtil.newArrayList();
    String message = "subject containing  symbol in it\n\ncommit body containing  symbol in it";
    touch("file.txt", "content");
    addCommit(message);
    GitHistoryUtils.loadDetails(myProject, myRepo.getRoot(), details::add);
    VcsFullCommitDetails lastCommit = ContainerUtil.getFirstItem(details);
    assertNotNull(lastCommit);
    assertEquals(message, lastCommit.getFullMessage());
}
Also used : VcsFullCommitDetails(com.intellij.vcs.log.VcsFullCommitDetails) Test(org.testng.annotations.Test) GitSingleRepoTest(git4idea.test.GitSingleRepoTest)

Example 7 with VcsFullCommitDetails

use of com.intellij.vcs.log.VcsFullCommitDetails in project intellij-community by JetBrains.

the class CommitSelectionListenerForDiff method onDetailsLoaded.

@Override
protected void onDetailsLoaded(@NotNull List<VcsFullCommitDetails> detailsList) {
    List<Change> changes = ContainerUtil.newArrayList();
    List<VcsFullCommitDetails> detailsListReversed = ContainerUtil.reverse(detailsList);
    for (VcsFullCommitDetails details : detailsListReversed) {
        changes.addAll(details.getChanges());
    }
    changes = CommittedChangesTreeBrowser.zipChanges(changes);
    setChangesToDisplay(changes);
}
Also used : Change(com.intellij.openapi.vcs.changes.Change) VcsFullCommitDetails(com.intellij.vcs.log.VcsFullCommitDetails)

Example 8 with VcsFullCommitDetails

use of com.intellij.vcs.log.VcsFullCommitDetails in project intellij-community by JetBrains.

the class CompareRevisionsFromHistoryAction method update.

public void update(@NotNull AnActionEvent e) {
    Project project = e.getProject();
    FileHistoryUi ui = e.getData(VcsLogInternalDataKeys.FILE_HISTORY_UI);
    FilePath filePath = e.getData(VcsDataKeys.FILE_PATH);
    if (project == null || ui == null || filePath == null) {
        e.getPresentation().setEnabledAndVisible(false);
        return;
    }
    e.getPresentation().setVisible(true);
    List<VcsFullCommitDetails> details = ui.getVcsLog().getSelectedDetails();
    if (e.getInputEvent() instanceof KeyEvent) {
        e.getPresentation().setEnabled(true);
    } else {
        if (details.size() == 2) {
            VcsFullCommitDetails detail0 = details.get(0);
            VcsFullCommitDetails detail1 = details.get(1);
            if (detail0 != null && !(detail0 instanceof LoadingDetails) && detail1 != null && !(detail1 instanceof LoadingDetails)) {
                VcsFileRevision newestRevision = ui.createRevision(detail0);
                VcsFileRevision olderRevision = ui.createRevision(detail1);
                e.getPresentation().setEnabled(newestRevision != null && olderRevision != null && !filePath.isDirectory());
            } else {
                e.getPresentation().setEnabled(!filePath.isDirectory());
            }
        } else {
            e.getPresentation().setEnabled(details.size() == 1);
        }
    }
    if (details.size() == 2) {
        e.getPresentation().setText(COMPARE_TEXT);
        e.getPresentation().setDescription(COMPARE_DESCRIPTION);
    } else {
        e.getPresentation().setText(DIFF_TEXT);
        e.getPresentation().setDescription(DIFF_DESCRIPTION);
    }
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) KeyEvent(java.awt.event.KeyEvent) Project(com.intellij.openapi.project.Project) LoadingDetails(com.intellij.vcs.log.data.LoadingDetails) FileHistoryUi(com.intellij.vcs.log.history.FileHistoryUi) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision) VcsFullCommitDetails(com.intellij.vcs.log.VcsFullCommitDetails)

Example 9 with VcsFullCommitDetails

use of com.intellij.vcs.log.VcsFullCommitDetails in project intellij-community by JetBrains.

the class VcsLogStructureFilterImpl method matches.

@Override
public boolean matches(@NotNull VcsCommitMetadata details) {
    if ((details instanceof VcsFullCommitDetails)) {
        for (Change change : ((VcsFullCommitDetails) details).getChanges()) {
            ContentRevision before = change.getBeforeRevision();
            if (before != null && matches(before.getFile().getPath())) {
                return true;
            }
            ContentRevision after = change.getAfterRevision();
            if (after != null && matches(after.getFile().getPath())) {
                return true;
            }
        }
        return false;
    } else {
        return false;
    }
}
Also used : ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) Change(com.intellij.openapi.vcs.changes.Change) VcsFullCommitDetails(com.intellij.vcs.log.VcsFullCommitDetails)

Example 10 with VcsFullCommitDetails

use of com.intellij.vcs.log.VcsFullCommitDetails in project intellij-community by JetBrains.

the class GitCherryPicker method cherryPick.

// return true to continue with other roots, false to break execution
private boolean cherryPick(@NotNull GitRepository repository, @NotNull List<VcsFullCommitDetails> commits, @NotNull List<GitCommitWrapper> successfulCommits, @NotNull List<GitCommitWrapper> alreadyPicked) {
    for (VcsFullCommitDetails commit : commits) {
        GitSimpleEventDetector conflictDetector = new GitSimpleEventDetector(CHERRY_PICK_CONFLICT);
        GitSimpleEventDetector localChangesOverwrittenDetector = new GitSimpleEventDetector(LOCAL_CHANGES_OVERWRITTEN_BY_CHERRY_PICK);
        GitUntrackedFilesOverwrittenByOperationDetector untrackedFilesDetector = new GitUntrackedFilesOverwrittenByOperationDetector(repository.getRoot());
        boolean autoCommit = isAutoCommit();
        GitCommandResult result = myGit.cherryPick(repository, commit.getId().asString(), autoCommit, conflictDetector, localChangesOverwrittenDetector, untrackedFilesDetector);
        GitCommitWrapper commitWrapper = new GitCommitWrapper(commit);
        if (result.success()) {
            if (autoCommit) {
                successfulCommits.add(commitWrapper);
            } else {
                boolean committed = updateChangeListManagerShowCommitDialogAndRemoveChangeListOnSuccess(repository, commitWrapper, successfulCommits, alreadyPicked);
                if (!committed) {
                    notifyCommitCancelled(commitWrapper, successfulCommits);
                    return false;
                }
            }
        } else if (conflictDetector.hasHappened()) {
            boolean mergeCompleted = new CherryPickConflictResolver(myProject, myGit, repository.getRoot(), commit.getId().asString(), VcsUserUtil.getShortPresentation(commit.getAuthor()), commit.getSubject()).merge();
            if (mergeCompleted) {
                boolean committed = updateChangeListManagerShowCommitDialogAndRemoveChangeListOnSuccess(repository, commitWrapper, successfulCommits, alreadyPicked);
                if (!committed) {
                    notifyCommitCancelled(commitWrapper, successfulCommits);
                    return false;
                }
            } else {
                updateChangeListManager(commit);
                notifyConflictWarning(repository, commitWrapper, successfulCommits);
                return false;
            }
        } else if (untrackedFilesDetector.wasMessageDetected()) {
            String description = commitDetails(commitWrapper) + "<br/>Some untracked working tree files would be overwritten by cherry-pick.<br/>" + "Please move, remove or add them before you can cherry-pick. <a href='view'>View them</a>";
            description += getSuccessfulCommitDetailsIfAny(successfulCommits);
            GitUntrackedFilesHelper.notifyUntrackedFilesOverwrittenBy(myProject, repository.getRoot(), untrackedFilesDetector.getRelativeFilePaths(), "cherry-pick", description);
            return false;
        } else if (localChangesOverwrittenDetector.hasHappened()) {
            notifyError("Your local changes would be overwritten by cherry-pick.<br/>Commit your changes or stash them to proceed.", commitWrapper, successfulCommits);
            return false;
        } else if (isNothingToCommitMessage(result)) {
            alreadyPicked.add(commitWrapper);
        } else {
            notifyError(result.getErrorOutputAsHtmlString(), commitWrapper, successfulCommits);
            return false;
        }
    }
    return true;
}
Also used : GitSimpleEventDetector(git4idea.commands.GitSimpleEventDetector) GitUntrackedFilesOverwrittenByOperationDetector(git4idea.commands.GitUntrackedFilesOverwrittenByOperationDetector) GitCommandResult(git4idea.commands.GitCommandResult) VcsFullCommitDetails(com.intellij.vcs.log.VcsFullCommitDetails)

Aggregations

VcsFullCommitDetails (com.intellij.vcs.log.VcsFullCommitDetails)12 Project (com.intellij.openapi.project.Project)4 NotNull (org.jetbrains.annotations.NotNull)4 Change (com.intellij.openapi.vcs.changes.Change)3 FileHistoryUi (com.intellij.vcs.log.history.FileHistoryUi)3 FilePath (com.intellij.openapi.vcs.FilePath)2 VcsFileRevision (com.intellij.openapi.vcs.history.VcsFileRevision)2 LoadingDetails (com.intellij.vcs.log.data.LoadingDetails)2 List (java.util.List)2 OutgoingResult (com.intellij.dvcs.push.OutgoingResult)1 VcsError (com.intellij.dvcs.push.VcsError)1 VcsException (com.intellij.openapi.vcs.VcsException)1 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)1 ShowDiffContext (com.intellij.openapi.vcs.changes.actions.diff.ShowDiffContext)1 ObjectUtils.chooseNotNull (com.intellij.util.ObjectUtils.chooseNotNull)1 CommitId (com.intellij.vcs.log.CommitId)1 VcsLog (com.intellij.vcs.log.VcsLog)1 GitCommit (git4idea.GitCommit)1 GitLocalBranch (git4idea.GitLocalBranch)1 GitCommandResult (git4idea.commands.GitCommandResult)1