use of org.zmlx.hg4idea.HgFile in project intellij-community by JetBrains.
the class HgDiffProvider method createFileContent.
public ContentRevision createFileContent(VcsRevisionNumber revisionNumber, VirtualFile file) {
if (file == null) {
return null;
}
VirtualFile vcsRoot = VcsUtil.getVcsRootFor(project, file);
if (vcsRoot == null) {
return null;
}
HgRevisionNumber hgRevisionNumber = (HgRevisionNumber) revisionNumber;
if (hgRevisionNumber.isWorkingVersion()) {
throw new IllegalStateException("Should not compare against working copy");
}
HgFile hgFile = new HgFile(vcsRoot, HgUtil.getOriginalFileName(VcsUtil.getFilePath(file), ChangeListManager.getInstance(project)));
return HgContentRevision.create(project, hgFile, hgRevisionNumber);
}
use of org.zmlx.hg4idea.HgFile in project intellij-community by JetBrains.
the class HgHistoryProvider method getHistoryForUncommittedRenamed.
/**
* Workaround for getting follow file history in case of uncommitted move/rename change
*/
private static List<HgFileRevision> getHistoryForUncommittedRenamed(@NotNull FilePath originalHgFilePath, @NotNull VirtualFile vcsRoot, @NotNull Project project, int limit) {
HgFile originalHgFile = new HgFile(vcsRoot, originalHgFilePath);
final HgLogCommand logCommand = new HgLogCommand(project);
logCommand.setIncludeRemoved(true);
final HgVersion version = logCommand.getVersion();
String[] templates = HgBaseLogParser.constructFullTemplateArgument(false, version);
String template = HgChangesetUtil.makeTemplate(templates);
List<String> argsForCmd = ContainerUtil.newArrayList();
String relativePath = originalHgFile.getRelativePath();
argsForCmd.add("--rev");
argsForCmd.add(String.format("reverse(follow(%s))", relativePath != null ? "'" + FileUtil.toSystemIndependentName(relativePath) + "'" : ""));
HgCommandResult result = logCommand.execute(vcsRoot, template, limit, relativePath != null ? null : originalHgFile, argsForCmd);
return HgHistoryUtil.getCommitRecords(project, result, new HgFileRevisionLogParser(project, originalHgFile, version));
}
use of org.zmlx.hg4idea.HgFile in project intellij-community by JetBrains.
the class HgLogCommand method execute.
/**
* @param limit Pass -1 to set no limits on history
*/
public final List<HgFileRevision> execute(final HgFile hgFile, int limit, boolean includeFiles, @Nullable List<String> argsForCmd) {
if ((limit <= 0 && limit != -1) || hgFile == null) {
return Collections.emptyList();
}
String[] templates = HgBaseLogParser.constructFullTemplateArgument(includeFiles, myVersion);
String template = HgChangesetUtil.makeTemplate(templates);
FilePath originalFileName = HgUtil.getOriginalFileName(hgFile.toFilePath(), ChangeListManager.getInstance(myProject));
HgFile originalHgFile = new HgFile(hgFile.getRepo(), originalFileName);
HgCommandResult result = execute(hgFile.getRepo(), template, limit, originalHgFile, argsForCmd);
return HgHistoryUtil.getCommitRecords(myProject, result, new HgFileRevisionLogParser(myProject, originalHgFile, myVersion));
}
use of org.zmlx.hg4idea.HgFile in project intellij-community by JetBrains.
the class HgResolveCommand method handleResult.
private static Map<HgFile, HgResolveStatusEnum> handleResult(VirtualFile repo, HgCommandResult result) {
final Map<HgFile, HgResolveStatusEnum> resolveStatus = new HashMap<>();
for (String line : result.getOutputLines()) {
if (StringUtil.isEmptyOrSpaces(line) || line.length() < ITEM_COUNT) {
continue;
}
final HgResolveStatusEnum status = HgResolveStatusEnum.valueOf(line.charAt(0));
if (status != null) {
File ioFile = new File(repo.getPath(), line.substring(2));
resolveStatus.put(new HgFile(repo, ioFile), status);
}
}
return resolveStatus;
}
use of org.zmlx.hg4idea.HgFile in project intellij-community by JetBrains.
the class HgAnnotationTest method annotationWithWhitespaceOption.
private void annotationWithWhitespaceOption(boolean ignoreWhitespaces) {
cd(myRepository);
String whitespaceFile = "whitespaces.txt";
touch(whitespaceFile, "not whitespaces");
myRepository.refresh(false, true);
String whiteSpaceAuthor = "Mr.Whitespace";
final VirtualFile file = myRepository.findFileByRelativePath(whitespaceFile);
assert file != null;
hg("add " + whitespaceFile);
hg("commit -m modify -u '" + defaultAuthor + "'");
//add several whitespaces
echo(whitespaceFile, " ");
hg("commit -m whitespaces -u '" + whiteSpaceAuthor + "'");
final HgFile hgFile = new HgFile(myRepository, VfsUtilCore.virtualToIoFile(file));
myVcs.getProjectSettings().setIgnoreWhitespacesInAnnotations(ignoreWhitespaces);
List<HgAnnotationLine> annotationLines = new HgAnnotateCommand(myProject).execute(hgFile, null);
HgAnnotationLine line = annotationLines.get(0);
assertEquals(ignoreWhitespaces ? defaultAuthor : whiteSpaceAuthor, line.get(HgAnnotation.FIELD.USER));
}
Aggregations