use of com.intellij.openapi.vcs.changes.ContentRevision in project intellij-community by JetBrains.
the class GitNewChangesCollector method reportAdded.
private void reportAdded(String filepath) throws VcsException {
ContentRevision before = null;
ContentRevision after = GitContentRevision.createRevision(myVcsRoot, filepath, null, myProject, false, false, false);
reportChange(FileStatus.ADDED, before, after);
}
use of com.intellij.openapi.vcs.changes.ContentRevision in project intellij-community by JetBrains.
the class GitOldChangesCollector method parseFiles.
private void parseFiles(String list) throws VcsException {
for (StringScanner sc = new StringScanner(list); sc.hasMoreData(); ) {
if (sc.isEol()) {
sc.nextLine();
continue;
}
char status = sc.peek();
sc.skipChars(2);
if ('?' == status) {
VirtualFile file = myVcsRoot.findFileByRelativePath(GitUtil.unescapePath(sc.line()));
if (Comparing.equal(GitUtil.gitRootOrNull(file), myVcsRoot)) {
myUnversioned.add(file);
}
} else {
//noinspection HardCodedStringLiteral
if ('M' == status) {
sc.boundedToken('\t');
String file = GitUtil.unescapePath(sc.line());
VirtualFile vFile = myVcsRoot.findFileByRelativePath(file);
if (!Comparing.equal(GitUtil.gitRootOrNull(vFile), myVcsRoot)) {
continue;
}
if (!myUnmergedNames.add(file)) {
continue;
}
// assume modify-modify conflict
ContentRevision before = GitContentRevision.createRevision(myVcsRoot, file, new GitRevisionNumber("orig_head"), myProject, false, true, true);
ContentRevision after = GitContentRevision.createRevision(myVcsRoot, file, null, myProject, false, false, true);
myChanges.add(new Change(before, after, FileStatus.MERGED_WITH_CONFLICTS));
} else {
throw new VcsException("Unsupported type of the merge conflict detected: " + status);
}
}
}
}
use of com.intellij.openapi.vcs.changes.ContentRevision in project intellij-community by JetBrains.
the class GitMergeUpdater method getLocalChangesFilteredByFiles.
private Collection<Change> getLocalChangesFilteredByFiles(List<FilePath> paths) {
final Collection<Change> changes = new HashSet<>();
for (LocalChangeList list : myChangeListManager.getChangeLists()) {
for (Change change : list.getChanges()) {
final ContentRevision afterRevision = change.getAfterRevision();
final ContentRevision beforeRevision = change.getBeforeRevision();
if ((afterRevision != null && paths.contains(afterRevision.getFile())) || (beforeRevision != null && paths.contains(beforeRevision.getFile()))) {
changes.add(change);
}
}
}
return changes;
}
use of com.intellij.openapi.vcs.changes.ContentRevision in project intellij-community by JetBrains.
the class TestDiscoverySearchHelper method getAffectedFiles.
@NotNull
private static List<VirtualFile> getAffectedFiles(String changeListName, Project project) {
final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
if ("All".equals(changeListName)) {
return changeListManager.getAffectedFiles();
}
final LocalChangeList changeList = changeListManager.findChangeList(changeListName);
if (changeList != null) {
List<VirtualFile> files = new ArrayList<>();
for (Change change : changeList.getChanges()) {
final ContentRevision afterRevision = change.getAfterRevision();
if (afterRevision != null) {
final VirtualFile file = afterRevision.getFile().getVirtualFile();
if (file != null) {
files.add(file);
}
}
}
return files;
}
return Collections.emptyList();
}
use of com.intellij.openapi.vcs.changes.ContentRevision in project intellij-community by JetBrains.
the class BaseAnalysisActionDialog method getScope.
@NotNull
public AnalysisScope getScope(@NotNull AnalysisUIOptions uiOptions, @NotNull AnalysisScope defaultScope, @NotNull Project project, Module module) {
AnalysisScope scope;
if (isProjectScopeSelected()) {
scope = new AnalysisScope(project);
uiOptions.SCOPE_TYPE = AnalysisScope.PROJECT;
} else {
final SearchScope customScope = getCustomScope();
if (customScope != null) {
scope = new AnalysisScope(customScope, project);
uiOptions.SCOPE_TYPE = AnalysisScope.CUSTOM;
uiOptions.CUSTOM_SCOPE_NAME = customScope.getDisplayName();
} else if (isModuleScopeSelected()) {
scope = new AnalysisScope(module);
uiOptions.SCOPE_TYPE = AnalysisScope.MODULE;
} else if (isUncommitedFilesSelected()) {
final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
List<VirtualFile> files;
if (myChangeLists.getSelectedItem() == ALL) {
files = changeListManager.getAffectedFiles();
} else {
files = new ArrayList<>();
for (ChangeList list : changeListManager.getChangeListsCopy()) {
if (!Comparing.strEqual(list.getName(), (String) myChangeLists.getSelectedItem()))
continue;
final Collection<Change> changes = list.getChanges();
for (Change change : changes) {
final ContentRevision afterRevision = change.getAfterRevision();
if (afterRevision != null) {
final VirtualFile vFile = afterRevision.getFile().getVirtualFile();
if (vFile != null) {
files.add(vFile);
}
}
}
}
}
scope = new AnalysisScope(project, new HashSet<>(files));
uiOptions.SCOPE_TYPE = AnalysisScope.UNCOMMITTED_FILES;
} else {
scope = defaultScope;
//just not project scope
uiOptions.SCOPE_TYPE = defaultScope.getScopeType();
}
}
uiOptions.ANALYZE_TEST_SOURCES = isInspectTestSources();
scope.setIncludeTestSource(isInspectTestSources());
FindSettings.getInstance().setDefaultScopeName(scope.getDisplayName());
return scope;
}
Aggregations