当前位置: 首页>>代码示例>>Java>>正文


Java MergeData类代码示例

本文整理汇总了Java中com.intellij.openapi.vcs.merge.MergeData的典型用法代码示例。如果您正苦于以下问题:Java MergeData类的具体用法?Java MergeData怎么用?Java MergeData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MergeData类属于com.intellij.openapi.vcs.merge包,在下文中一共展示了MergeData类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: step

import com.intellij.openapi.vcs.merge.MergeData; //导入依赖的package包/类
@Override
public MyResult step(DiffChainContext context) {
  if (myChange.getAfterRevision() == null) return createErrorResult();
  FileType type = myChange.getVirtualFile() != null ? myChange.getVirtualFile().getFileType() : null;
  if (myFile.getFileType().isBinary()) {
    final boolean nowItIsText = ChangeDiffRequestPresentable.checkAssociate(myProject, myFile.getName(), context);
    if (! nowItIsText) {
      return createErrorResult();
    }
  }
  final AbstractVcs vcs = ChangesUtil.getVcsForChange(myChange, myProject);
  if (vcs == null || vcs.getMergeProvider() == null) {
    return createErrorResult();
  }
  try {
    final MergeData mergeData = vcs.getMergeProvider().loadRevisions(myFile);
    final Charset charset = myFile.getCharset();
    final MergeRequest request = DiffRequestFactory.getInstance()
      .create3WayDiffRequest(CharsetToolkit.bytesToString(mergeData.CURRENT, charset),
                             CharsetToolkit.bytesToString(mergeData.LAST, charset),
                             CharsetToolkit.bytesToString(mergeData.ORIGINAL, charset),
                             type, myProject, null, null);
    request.setWindowTitle(FileUtil.toSystemDependentName(myFile.getPresentableUrl()));
    // todo titles?
    VcsRevisionNumber lastRevisionNumber = mergeData.LAST_REVISION_NUMBER;
    request.setVersionTitles(new String[]{myChange.getAfterRevision().getRevisionNumber().asString(),
      "Base Version", lastRevisionNumber != null ? lastRevisionNumber.asString() : ""});
    return new MyResult(request, DiffPresentationReturnValue.useRequest);
  }
  catch (VcsException e) {
    LOG.info(e);
    return createErrorResult();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:ConflictedDiffRequestPresentable.java

示例2: loadRevisions

import com.intellij.openapi.vcs.merge.MergeData; //导入依赖的package包/类
@Override
@NotNull
public MergeData loadRevisions(@NotNull final VirtualFile file) throws VcsException {
  final MergeData mergeData = new MergeData();
  final VirtualFile root = GitUtil.getGitRoot(file);
  final FilePath path = VcsUtil.getFilePath(file.getPath());

  VcsRunnable runnable = new VcsRunnable() {
    @Override
    @SuppressWarnings({"ConstantConditions"})
    public void run() throws VcsException {
      GitFileRevision original = new GitFileRevision(myProject, path, new GitRevisionNumber(":" + ORIGINAL_REVISION_NUM));
      GitFileRevision current = new GitFileRevision(myProject, path, new GitRevisionNumber(":" + yoursRevision(root)));
      GitFileRevision last = new GitFileRevision(myProject, path, new GitRevisionNumber(":" + theirsRevision(root)));
      try {
        try {
          mergeData.ORIGINAL = original.getContent();
        }
        catch (Exception ex) {
          /// unable to load original revision, use the current instead
          /// This could happen in case if rebasing.
          mergeData.ORIGINAL = file.contentsToByteArray();
        }
        mergeData.CURRENT = loadRevisionCatchingErrors(current);
        mergeData.LAST = loadRevisionCatchingErrors(last);
        mergeData.LAST_REVISION_NUMBER = findLastRevisionNumber(root);
      }
      catch (IOException e) {
        throw new IllegalStateException("Failed to load file content", e);
      }
    }
  };
  VcsUtil.runVcsProcessWithProgress(runnable, GitBundle.message("merge.load.files"), false, myProject);
  return mergeData;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:GitMergeProvider.java

示例3: verifyMergeData

import com.intellij.openapi.vcs.merge.MergeData; //导入依赖的package包/类
private void verifyMergeData(final VirtualFile file, String expectedBase, String expectedLocal, String expectedServer)
  throws VcsException {
  final MergeData mergeData = myMergeProvider.loadRevisions(file);
  assertEquals(expectedBase, mergeData.ORIGINAL);
  assertEquals(expectedServer, mergeData.LAST);
  assertEquals(expectedLocal, mergeData.CURRENT);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:HgMergeProviderTest.java

示例4: loadRevisions

import com.intellij.openapi.vcs.merge.MergeData; //导入依赖的package包/类
@NotNull
public MergeData loadRevisions(final VirtualFile file) throws VcsException {
  final MergeData mergeData = new MergeData();
  if (file == null) return mergeData;
  final VirtualFile root = GitUtil.getGitRoot(file);
  final FilePath path = VcsUtil.getFilePath(file.getPath());

  VcsRunnable runnable = new VcsRunnable() {
    @SuppressWarnings({"ConstantConditions"})
    public void run() throws VcsException {
      GitFileRevision original = new GitFileRevision(myProject, path, new GitRevisionNumber(":" + ORIGINAL_REVISION_NUM));
      GitFileRevision current = new GitFileRevision(myProject, path, new GitRevisionNumber(":" + yoursRevision(root)));
      GitFileRevision last = new GitFileRevision(myProject, path, new GitRevisionNumber(":" + theirsRevision(root)));
      try {
        try {
          mergeData.ORIGINAL = original.getContent();
        }
        catch (Exception ex) {
          /// unable to load original revision, use the current instead
          /// This could happen in case if rebasing.
          mergeData.ORIGINAL = file.contentsToByteArray();
        }
        mergeData.CURRENT = loadRevisionCatchingErrors(current);
        mergeData.LAST = loadRevisionCatchingErrors(last);
        mergeData.LAST_REVISION_NUMBER = findLastRevisionNumber(root);
      }
      catch (IOException e) {
        throw new IllegalStateException("Failed to load file content", e);
      }
    }
  };
  VcsUtil.runVcsProcessWithProgress(runnable, GitBundle.message("merge.load.files"), false, myProject);
  return mergeData;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:35,代码来源:GitMergeProvider.java

示例5: putRevisionInfos

import com.intellij.openapi.vcs.merge.MergeData; //导入依赖的package包/类
public static void putRevisionInfos(@Nonnull DiffRequest request, @Nonnull MergeData data) {
  if (request instanceof ContentDiffRequest) {
    List<? extends DiffContent> contents = ((ContentDiffRequest)request).getContents();
    if (contents.size() == 3) {
      putRevisionInfo(contents, data);
    }
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:9,代码来源:MergeUtil.java

示例6: putRevisionInfo

import com.intellij.openapi.vcs.merge.MergeData; //导入依赖的package包/类
private static void putRevisionInfo(@Nonnull List<? extends DiffContent> contents, @Nonnull MergeData data) {
  for (ThreeSide side : ThreeSide.values()) {
    DiffContent content = side.select(contents);
    FilePath filePath = side.select(data.CURRENT_FILE_PATH, data.ORIGINAL_FILE_PATH, data.LAST_FILE_PATH);
    VcsRevisionNumber revision = side.select(data.CURRENT_REVISION_NUMBER, data.ORIGINAL_REVISION_NUMBER, data.LAST_REVISION_NUMBER);
    if (filePath != null && revision != null) {
      content.putUserData(DiffUserDataKeysEx.REVISION_INFO, Pair.create(filePath, revision));
    }
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:11,代码来源:MergeUtil.java

示例7: step

import com.intellij.openapi.vcs.merge.MergeData; //导入依赖的package包/类
@Override
public MyResult step(DiffChainContext context) {
  if (myChange.getAfterRevision() == null) return createErrorResult();
  FileType type = myChange.getVirtualFile() != null ? myChange.getVirtualFile().getFileType() : null;
  if (myFile.getFileType().isBinary()) {
    final boolean nowItIsText = ChangeDiffRequestPresentable.checkAssociate(myProject, myFile.getName(), context);
    if (! nowItIsText) {
      return createErrorResult();
    }
  }
  final AbstractVcs vcs = ChangesUtil.getVcsForChange(myChange, myProject);
  if (vcs == null || vcs.getMergeProvider() == null) {
    return createErrorResult();
  }
  try {
    final MergeData mergeData = vcs.getMergeProvider().loadRevisions(myFile);
    final Charset charset = myFile.getCharset();
    final MergeRequest request = DiffRequestFactory.getInstance()
            .create3WayDiffRequest(CharsetToolkit.bytesToString(mergeData.CURRENT, charset),
                                   CharsetToolkit.bytesToString(mergeData.LAST, charset),
                                   CharsetToolkit.bytesToString(mergeData.ORIGINAL, charset),
                                   type, myProject, null, null);
    request.setWindowTitle(FileUtil.toSystemDependentName(myFile.getPresentableUrl()));
    // todo titles?
    VcsRevisionNumber lastRevisionNumber = mergeData.LAST_REVISION_NUMBER;
    request.setVersionTitles(new String[]{myChange.getAfterRevision().getRevisionNumber().asString(),
            "Base Version", lastRevisionNumber != null ? lastRevisionNumber.asString() : ""});
    return new MyResult(request, DiffPresentationReturnValue.useRequest);
  }
  catch (VcsException e) {
    LOG.info(e);
    return createErrorResult();
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:35,代码来源:ConflictedDiffRequestPresentable.java

示例8: loadRevisions

import com.intellij.openapi.vcs.merge.MergeData; //导入依赖的package包/类
@NotNull
public MergeData loadRevisions(@NotNull final VirtualFile file) throws VcsException {
  final MergeData data = new MergeData();
  VcsRunnable runnable = new VcsRunnable() {
    public void run() throws VcsException {
      File oldFile = null;
      File newFile = null;
      File workingFile = null;
      boolean mergeCase = false;
      SvnVcs vcs = SvnVcs.getInstance(myProject);
      Info info = vcs.getInfo(file);

      if (info != null) {
        oldFile = info.getConflictOldFile();
        newFile = info.getConflictNewFile();
        workingFile = info.getConflictWrkFile();
        mergeCase = workingFile == null || workingFile.getName().contains("working");
        // for debug
        if (workingFile == null) {
          LOG.info("Null working file when merging text conflict for " + file.getPath() + " old file: " + oldFile + " new file: " + newFile);
        }
        if (mergeCase) {
          // this is merge case
          oldFile = info.getConflictNewFile();
          newFile = info.getConflictOldFile();
          workingFile = info.getConflictWrkFile();
        }
        data.LAST_REVISION_NUMBER = new SvnRevisionNumber(info.getRevision());
      } else {
        throw new VcsException("Could not get info for " + file.getPath());
      }
      if (oldFile == null || newFile == null || workingFile == null) {
        ByteArrayOutputStream bos = getBaseRevisionContents(vcs, file);
        data.ORIGINAL = bos.toByteArray();
        data.LAST = bos.toByteArray();
        data.CURRENT = readFile(new File(file.getPath()));
      }
      else {
        data.ORIGINAL = readFile(oldFile);
        data.LAST = readFile(newFile);
        data.CURRENT = readFile(workingFile);
      }
      if (mergeCase) {
        final ByteArrayOutputStream contents = getBaseRevisionContents(vcs, file);
        if (! Arrays.equals(contents.toByteArray(), data.ORIGINAL)) {
          // swap base and server: another order of merge arguments
          byte[] original = data.ORIGINAL;
          data.ORIGINAL = data.LAST;
          data.LAST = original;
        }
      }
    }
  };
  VcsUtil.runVcsProcessWithProgress(runnable, VcsBundle.message("multiple.file.merge.loading.progress.title"), false, myProject);

  return data;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:58,代码来源:SvnMergeProvider.java

示例9: loadRevisions

import com.intellij.openapi.vcs.merge.MergeData; //导入依赖的package包/类
@NotNull
public MergeData loadRevisions(final VirtualFile file) throws VcsException {
  final MergeData data = new MergeData();
  VcsRunnable runnable = new VcsRunnable() {
    public void run() throws VcsException {
      SvnVcs vcs = SvnVcs.getInstance(myProject);
      File oldFile = null;
      File newFile = null;
      File workingFile = null;
      SVNWCClient client;
      boolean mergeCase = false;
      try {
        client = vcs.createWCClient();
        SVNInfo info = client.doInfo(new File(file.getPath()), SVNRevision.UNDEFINED);
        if (info != null) {
          oldFile = info.getConflictOldFile();
          newFile = info.getConflictNewFile();
          workingFile = info.getConflictWrkFile();
          mergeCase = workingFile == null || workingFile.getName().contains("working");
          // for debug
          if (workingFile == null) {
            LOG.info("Null working file when merging text conflict for " + file.getPath() + " old file: " + oldFile + " new file: " + newFile);
          }
          if (mergeCase) {
            // this is merge case
            oldFile = info.getConflictNewFile();
            newFile = info.getConflictOldFile();
            workingFile = info.getConflictWrkFile();
          }
          data.LAST_REVISION_NUMBER = new SvnRevisionNumber(info.getRevision());
        }
      }
      catch (SVNException e) {
        throw new VcsException(e);
      }
      if (oldFile == null || newFile == null || workingFile == null) {
        ByteArrayOutputStream bos = getBaseRevisionContents(client, file);
        data.ORIGINAL = bos.toByteArray();
        data.LAST = bos.toByteArray();
        data.CURRENT = readFile(new File(file.getPath()));
      }
      else {
        data.ORIGINAL = readFile(oldFile);
        data.LAST = readFile(newFile);
        data.CURRENT = readFile(workingFile);
      }
      if (mergeCase) {
        final ByteArrayOutputStream contents = getBaseRevisionContents(vcs.createWCClient(), file);
        if (! Arrays.equals(contents.toByteArray(), data.ORIGINAL)) {
          // swap base and server: another order of merge arguments
          byte[] original = data.ORIGINAL;
          data.ORIGINAL = data.LAST;
          data.LAST = original;
        }
      }
    }
  };
  VcsUtil.runVcsProcessWithProgress(runnable, VcsBundle.message("multiple.file.merge.loading.progress.title"), false, myProject);

  return data;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:62,代码来源:SvnMergeProvider.java


注:本文中的com.intellij.openapi.vcs.merge.MergeData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。