use of com.intellij.openapi.vcs.FileStatus in project intellij-community by JetBrains.
the class HgUtil method getOriginalFileName.
@NotNull
public static FilePath getOriginalFileName(@NotNull FilePath filePath, ChangeListManager changeListManager) {
Change change = changeListManager.getChange(filePath);
if (change == null) {
return filePath;
}
FileStatus status = change.getFileStatus();
if (status == HgChangeProvider.COPIED || status == HgChangeProvider.RENAMED) {
ContentRevision beforeRevision = change.getBeforeRevision();
assert beforeRevision != null : "If a file's status is copied or renamed, there must be an previous version";
return beforeRevision.getFile();
} else {
return filePath;
}
}
use of com.intellij.openapi.vcs.FileStatus in project intellij-community by JetBrains.
the class HgUtil method getDiff.
@NotNull
public static List<Change> getDiff(@NotNull final Project project, @NotNull final VirtualFile root, @NotNull final FilePath path, @Nullable final HgRevisionNumber revNum1, @Nullable final HgRevisionNumber revNum2) {
HgStatusCommand statusCommand;
if (revNum1 != null) {
//rev2==null means "compare with local version"
statusCommand = new HgStatusCommand.Builder(true).ignored(false).unknown(false).copySource(!path.isDirectory()).baseRevision(revNum1).targetRevision(revNum2).build(project);
} else {
//rev1 and rev2 can't be null both//
LOG.assertTrue(revNum2 != null, "revision1 and revision2 can't both be null. Path: " + path);
//get initial changes//
statusCommand = new HgStatusCommand.Builder(true).ignored(false).unknown(false).copySource(false).baseRevision(revNum2).build(project);
}
Collection<HgChange> hgChanges = statusCommand.executeInCurrentThread(root, Collections.singleton(path));
List<Change> changes = new ArrayList<>();
//convert output changes to standard Change class
for (HgChange hgChange : hgChanges) {
FileStatus status = convertHgDiffStatus(hgChange.getStatus());
if (status != FileStatus.UNKNOWN) {
changes.add(HgHistoryUtil.createChange(project, root, hgChange.beforeFile().getRelativePath(), revNum1, hgChange.afterFile().getRelativePath(), revNum2, status));
}
}
return changes;
}
use of com.intellij.openapi.vcs.FileStatus in project intellij-community by JetBrains.
the class SvnChangeProviderContext method processStatus.
void processStatus(@NotNull FilePath filePath, @NotNull Status status) throws SVNException {
WorkingCopyFormat format = myVcs.getWorkingCopyFormat(filePath.getIOFile());
if (!WorkingCopyFormat.UNKNOWN.equals(format) && format.less(WorkingCopyFormat.ONE_DOT_SEVEN)) {
loadEntriesFile(filePath);
}
FileStatus fStatus = SvnStatusConvertor.convertStatus(status);
final StatusType statusType = status.getContentsStatus();
if (status.is(StatusType.STATUS_UNVERSIONED, StatusType.UNKNOWN)) {
final VirtualFile file = filePath.getVirtualFile();
if (file != null) {
myChangelistBuilder.processUnversionedFile(file);
}
} else if (status.is(StatusType.STATUS_ADDED)) {
processChangeInList(null, CurrentContentRevision.create(filePath), fStatus, status);
} else if (status.is(StatusType.STATUS_CONFLICTED, StatusType.STATUS_MODIFIED, StatusType.STATUS_REPLACED) || status.isProperty(StatusType.STATUS_MODIFIED, StatusType.STATUS_CONFLICTED)) {
processChangeInList(SvnContentRevision.createBaseRevision(myVcs, filePath, status), CurrentContentRevision.create(filePath), fStatus, status);
checkSwitched(filePath, status, fStatus);
} else if (status.is(StatusType.STATUS_DELETED)) {
processChangeInList(SvnContentRevision.createBaseRevision(myVcs, filePath, status), null, fStatus, status);
} else if (status.is(StatusType.STATUS_MISSING)) {
myChangelistBuilder.processLocallyDeletedFile(new SvnLocallyDeletedChange(filePath, getState(status)));
} else if (status.is(StatusType.STATUS_IGNORED)) {
VirtualFile file = filePath.getVirtualFile();
if (file == null) {
file = LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath.getPath());
}
if (file == null) {
LOG.error("No virtual file for ignored file: " + filePath.getPresentableUrl() + ", isNonLocal: " + filePath.isNonLocal());
} else if (!myVcs.isWcRoot(filePath)) {
myChangelistBuilder.processIgnoredFile(filePath.getVirtualFile());
}
} else if ((fStatus == FileStatus.NOT_CHANGED || fStatus == FileStatus.SWITCHED) && statusType != StatusType.STATUS_NONE) {
VirtualFile file = filePath.getVirtualFile();
if (file != null && FileDocumentManager.getInstance().isFileModified(file)) {
processChangeInList(SvnContentRevision.createBaseRevision(myVcs, filePath, status), CurrentContentRevision.create(filePath), FileStatus.MODIFIED, status);
} else if (status.getTreeConflict() != null) {
myChangelistBuilder.processChange(createChange(SvnContentRevision.createBaseRevision(myVcs, filePath, status), CurrentContentRevision.create(filePath), FileStatus.MODIFIED, status), SvnVcs.getKey());
}
checkSwitched(filePath, status, fStatus);
}
}
use of com.intellij.openapi.vcs.FileStatus in project intellij-community by JetBrains.
the class SvnChangeProviderContext method createPropertyChange.
@NotNull
private Change createPropertyChange(@NotNull Change change, @NotNull Status svnStatus, @Nullable Status deletedStatus) throws SVNException {
final File ioFile = ChangesUtil.getFilePath(change).getIOFile();
final File beforeFile = deletedStatus != null ? deletedStatus.getFile() : ioFile;
// TODO: There are cases when status output is like (on newly added file with some properties that is locally deleted)
// <entry path="some_path"> <wc-status item="missing" revision="-1" props="modified"> </wc-status> </entry>
// TODO: For such cases in current logic we'll have Change with before revision containing SVNRevision.UNDEFINED
// TODO: Analyze if this logic is OK or we should update flow somehow (for instance, to have null before revision)
ContentRevision beforeRevision = !svnStatus.isProperty(StatusType.STATUS_ADDED) || deletedStatus != null ? createPropertyRevision(change, beforeFile, true) : null;
ContentRevision afterRevision = !svnStatus.isProperty(StatusType.STATUS_DELETED) ? createPropertyRevision(change, ioFile, false) : null;
FileStatus status = deletedStatus != null ? FileStatus.MODIFIED : SvnStatusConvertor.convertPropertyStatus(svnStatus.getPropertiesStatus());
return new Change(beforeRevision, afterRevision, status);
}
use of com.intellij.openapi.vcs.FileStatus in project intellij-community by JetBrains.
the class SvnIgnoreTest method testImpl.
private void testImpl(VirtualFile file) {
VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
clManager.ensureUpToDate(false);
Assert.assertTrue(clManager.getDefaultChangeList().getChanges().isEmpty());
VcsDirtyScopeManager.getInstance(myProject).fileDirty(file);
clManager.ensureUpToDate(false);
Assert.assertTrue(clManager.getDefaultChangeList().getChanges().isEmpty());
final FileStatus status = clManager.getStatus(file);
Assert.assertTrue(status.getText(), FileStatus.IGNORED.equals(status));
}
Aggregations