use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.
the class HgUtil method removeFilesFromVcs.
/**
* Calls 'hg remove' to remove given files from the VCS.
* @param project
* @param files files to be removed from the VCS.
*/
public static void removeFilesFromVcs(Project project, List<FilePath> files) {
final HgRemoveCommand command = new HgRemoveCommand(project);
for (FilePath filePath : files) {
final VirtualFile vcsRoot = VcsUtil.getVcsRootFor(project, filePath);
if (vcsRoot == null) {
continue;
}
command.executeInCurrentThread(new HgFile(vcsRoot, filePath));
}
}
use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.
the class HgRepositoryUpdater method after.
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
// which files in .hg were changed
boolean branchHeadsChanged = false;
boolean branchFileChanged = false;
boolean dirstateFileChanged = false;
boolean mergeFileChanged = false;
boolean rebaseFileChanged = false;
boolean bookmarksFileChanged = false;
boolean tagsFileChanged = false;
boolean localTagsFileChanged = false;
boolean currentBookmarkFileChanged = false;
boolean mqChanged = false;
boolean hgIgnoreChanged = false;
boolean configHgrcChanged = false;
for (VFileEvent event : events) {
String filePath = event.getPath();
if (filePath == null) {
continue;
}
if (myRepositoryFiles.isbranchHeadsFile(filePath)) {
branchHeadsChanged = true;
} else if (myRepositoryFiles.isBranchFile(filePath)) {
branchFileChanged = true;
DvcsUtil.ensureAllChildrenInVfs(myBranchHeadsDir);
} else if (myRepositoryFiles.isDirstateFile(filePath)) {
dirstateFileChanged = true;
} else if (myRepositoryFiles.isMergeFile(filePath)) {
mergeFileChanged = true;
} else if (myRepositoryFiles.isRebaseFile(filePath)) {
rebaseFileChanged = true;
} else if (myRepositoryFiles.isBookmarksFile(filePath)) {
bookmarksFileChanged = true;
} else if (myRepositoryFiles.isTagsFile(filePath)) {
tagsFileChanged = true;
} else if (myRepositoryFiles.isLocalTagsFile(filePath)) {
localTagsFileChanged = true;
} else if (myRepositoryFiles.isCurrentBookmarksFile(filePath)) {
currentBookmarkFileChanged = true;
} else if (myRepositoryFiles.isMqFile(filePath)) {
mqChanged = true;
if (myMqDir == null) {
myMqDir = VcsUtil.getVirtualFile(myRepositoryFiles.getMQDirPath());
}
DvcsUtil.ensureAllChildrenInVfs(myMqDir);
} else if (myRepositoryFiles.isConfigHgrcFile(filePath)) {
configHgrcChanged = true;
} else if (myRepositoryFiles.isHgIgnore(filePath)) {
hgIgnoreChanged = true;
}
}
if (branchHeadsChanged || branchFileChanged || dirstateFileChanged || mergeFileChanged || rebaseFileChanged || bookmarksFileChanged || currentBookmarkFileChanged || tagsFileChanged || localTagsFileChanged || mqChanged) {
myUpdateQueue.queue(new MyUpdater("hgrepositoryUpdate"));
}
if (configHgrcChanged) {
myUpdateConfigQueue.queue(new MyUpdater("hgconfigUpdate"));
}
if (dirstateFileChanged || hgIgnoreChanged) {
myRepository.getLocalIgnoredHolder().startRescan();
final VirtualFile root = myRepository.getRoot();
myDirtyScopeManager.dirDirtyRecursively(root);
if (dirstateFileChanged) {
//update async incoming/outgoing model
myProject.getMessageBus().syncPublisher(HgVcs.REMOTE_TOPIC).update(myProject, root);
}
}
}
use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.
the class HgRemoteStatusUpdater method updateChangesStatusSynchronously.
private void updateChangesStatusSynchronously(Project project, VirtualFile[] roots, HgChangesetStatus status, boolean incoming) {
if (!myProjectSettings.isCheckIncomingOutgoing())
return;
final List<HgRevisionNumber> changesets = new LinkedList<>();
for (VirtualFile root : roots) {
if (incoming) {
changesets.addAll(new HgIncomingCommand(project).executeInCurrentThread(root));
} else {
changesets.addAll(new HgOutgoingCommand(project).executeInCurrentThread(root));
}
}
status.setChanges(changesets.size(), new ChangesetFormatter(status, changesets));
}
use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.
the class HgHistoryTest method testUncommittedRenamedFileHistory.
public void testUncommittedRenamedFileHistory() throws HgCommandException {
cd(myRepository);
VirtualFile subDir = myRepository.findFileByRelativePath(subDirName);
assert subDir != null;
cd(subDir);
int namesSize = names.length;
String beforeName = names[namesSize - 1];
VirtualFile before = VfsUtil.findFileByIoFile(new File(subDir.getPath(), beforeName), true);
assert before != null;
FilePath filePath = VcsUtil.getFilePath(VfsUtilCore.virtualToIoFile(before));
final String renamed = "renamed";
hg("mv " + beforeName + " " + renamed);
myRepository.refresh(false, true);
List<HgFileRevision> revisions = HgHistoryProvider.getHistory((filePath), myRepository, myProject);
assertEquals(3, revisions.size());
}
use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.
the class HgLogTest method parseCopied.
private void parseCopied(@NotNull String sourceFileName) throws HgCommandException {
cd(myRepository);
String copiedFileName = "copy".concat(sourceFileName);
touch(sourceFileName);
myRepository.refresh(false, true);
hg("add " + sourceFileName);
hg("commit -m a ");
hg("cp " + sourceFileName + " " + copiedFileName);
myRepository.refresh(false, true);
hg("commit -m a ");
HgLogCommand logCommand = new HgLogCommand(myProject);
logCommand.setFollowCopies(false);
VirtualFile copiedFile = myRepository.findChild(copiedFileName);
assert copiedFile != null;
final HgFile hgFile = new HgFile(myRepository, VfsUtilCore.virtualToIoFile(copiedFile));
List<HgFileRevision> revisions = logCommand.execute(hgFile, 1, true);
HgFileRevision rev = revisions.get(0);
assertTrue(!rev.getAddedFiles().isEmpty());
}
Aggregations