use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.
the class HgUtil method getRepositoryForFile.
@Nullable
public static HgRepository getRepositoryForFile(@NotNull Project project, @Nullable VirtualFile file) {
if (file == null || project.isDisposed())
return null;
HgRepositoryManager repositoryManager = getRepositoryManager(project);
VirtualFile root = getHgRootOrNull(project, file);
return repositoryManager.getRepositoryForRoot(root);
}
use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.
the class HgEncodingTest method testUtfMessageInHistoryWithSpecialCharacters.
//test SpecialCharacters in commit message for default EncodingProject settings
public void testUtfMessageInHistoryWithSpecialCharacters() throws HgCommandException, VcsException {
cd(myRepository);
String fileName = "file.txt";
echo(fileName, "lalala");
Charset charset = HgEncodingUtil.getDefaultCharset(myProject);
String comment = "öäüß";
HgRepository hgRepo = HgRepositoryImpl.getInstance(myRepository, myProject, myProject);
HgCommitCommand commitCommand = new HgCommitCommand(myProject, hgRepo, comment);
commitCommand.executeInCurrentThread();
HgLogCommand logCommand = new HgLogCommand(myProject);
myRepository.refresh(false, true);
VirtualFile file = myRepository.findChild(fileName);
assert file != null;
List<HgFileRevision> revisions = logCommand.execute(new HgFile(myProject, file), 1, false);
HgFileRevision rev = revisions.get(0);
assertEquals(new String(comment.getBytes(charset)), rev.getCommitMessage());
}
use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.
the class HgPlatformTest method setUpHgrc.
private static void setUpHgrc(@NotNull VirtualFile repositoryRoot) throws IOException {
cd(".hg");
File pluginRoot = new File(PluginPathManager.getPluginHomePath("hg4idea"));
String pathToHgrc = "testData\\repo\\dot_hg";
File hgrcFile = new File(new File(pluginRoot, FileUtil.toSystemIndependentName(pathToHgrc)), "hgrc");
File hgrc = new File(new File(repositoryRoot.getPath(), ".hg"), "hgrc");
FileUtil.appendToFile(hgrc, FileUtil.loadFile(hgrcFile));
assertTrue(hgrc.exists());
repositoryRoot.refresh(false, true);
}
use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.
the class HgTestUtil method printToFile.
/**
* Writes the given content to the file.
*
* @param file file which content will be substituted by the given one.
* @param content new file content
*/
public static void printToFile(@NotNull VirtualFile file, String content) throws FileNotFoundException {
PrintStream centralPrinter = null;
try {
centralPrinter = new PrintStream(new FileOutputStream(new File(file.getPath())));
centralPrinter.print(content);
centralPrinter.close();
} finally {
if (centralPrinter != null) {
centralPrinter.close();
}
}
}
use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.
the class HgAnnotationTest method testAnnotationWithVerboseOption.
public void testAnnotationWithVerboseOption() throws VcsException {
myRepository.refresh(false, true);
final VirtualFile file = myRepository.findFileByRelativePath(firstCreatedFile);
assert file != null;
List<String> users = Arrays.asList(defaultAuthor, author1, author2);
final HgFile hgFile = new HgFile(myRepository, VfsUtilCore.virtualToIoFile(file));
final String date = DateFormatUtil.formatPrettyDate(Clock.getTime());
List<HgAnnotationLine> annotationLines = new HgAnnotateCommand(myProject).execute(hgFile, null);
for (int i = 0; i < annotationLines.size(); ++i) {
HgAnnotationLine line = annotationLines.get(i);
assertEquals(users.get(i), line.get(HgAnnotation.FIELD.USER));
assertEquals(date, line.get(HgAnnotation.FIELD.DATE));
}
}
Aggregations