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());
}
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);
}
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);
}
}
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;
}
}
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;
}
Aggregations