Search in sources :

Example 1 with HgFileRevisionLogParser

use of org.zmlx.hg4idea.log.HgFileRevisionLogParser 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));
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgFile(org.zmlx.hg4idea.HgFile) HgFileRevisionLogParser(org.zmlx.hg4idea.log.HgFileRevisionLogParser)

Example 2 with HgFileRevisionLogParser

use of org.zmlx.hg4idea.log.HgFileRevisionLogParser 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));
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgFile(org.zmlx.hg4idea.HgFile) HgFileRevisionLogParser(org.zmlx.hg4idea.log.HgFileRevisionLogParser) HgVersion(org.zmlx.hg4idea.util.HgVersion) HgLogCommand(org.zmlx.hg4idea.command.HgLogCommand)

Aggregations

HgFile (org.zmlx.hg4idea.HgFile)2 HgCommandResult (org.zmlx.hg4idea.execution.HgCommandResult)2 HgFileRevisionLogParser (org.zmlx.hg4idea.log.HgFileRevisionLogParser)2 FilePath (com.intellij.openapi.vcs.FilePath)1 HgLogCommand (org.zmlx.hg4idea.command.HgLogCommand)1 HgVersion (org.zmlx.hg4idea.util.HgVersion)1