當前位置: 首頁>>代碼示例>>Java>>正文


Java DiffInfo類代碼示例

本文整理匯總了Java中com.google.gerrit.extensions.common.DiffInfo的典型用法代碼示例。如果您正苦於以下問題:Java DiffInfo類的具體用法?Java DiffInfo怎麽用?Java DiffInfo使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DiffInfo類屬於com.google.gerrit.extensions.common包,在下文中一共展示了DiffInfo類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: get

import com.google.gerrit.extensions.common.DiffInfo; //導入依賴的package包/類
private DiffInfo get(DiffRequest r) throws RestApiException {
  if (r.getBase() != null) {
    getDiff.setBase(r.getBase());
  }
  if (r.getContext() != null) {
    getDiff.setContext(r.getContext());
  }
  if (r.getIntraline() != null) {
    getDiff.setIntraline(r.getIntraline());
  }
  if (r.getWhitespace() != null) {
    getDiff.setWhitespace(r.getWhitespace());
  }
  r.getParent().ifPresent(getDiff::setParent);
  try {
    return getDiff.apply(file).value();
  } catch (Exception e) {
    throw asRestApiException("Cannot retrieve diff", e);
  }
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:21,代碼來源:FileApiImpl.java

示例2: diffOnMergeCommitChange

import com.google.gerrit.extensions.common.DiffInfo; //導入依賴的package包/類
@Test
public void diffOnMergeCommitChange() throws Exception {
  PushOneCommit.Result r = createMergeCommitChange("refs/for/master");

  DiffInfo diff;

  // automerge
  diff = getDiffRequest(r.getChangeId(), r.getCommit().name(), "foo").get();
  assertThat(diff.metaA.lines).isEqualTo(5);
  assertThat(diff.metaB.lines).isEqualTo(1);

  diff = getDiffRequest(r.getChangeId(), r.getCommit().name(), "bar").get();
  assertThat(diff.metaA.lines).isEqualTo(5);
  assertThat(diff.metaB.lines).isEqualTo(1);

  // parent 1
  diff = getDiffRequest(r.getChangeId(), r.getCommit().name(), "bar").withParent(1).get();
  assertThat(diff.metaA.lines).isEqualTo(1);
  assertThat(diff.metaB.lines).isEqualTo(1);

  // parent 2
  diff = getDiffRequest(r.getChangeId(), r.getCommit().name(), "foo").withParent(2).get();
  assertThat(diff.metaA.lines).isEqualTo(1);
  assertThat(diff.metaB.lines).isEqualTo(1);
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:26,代碼來源:RevisionDiffIT.java

示例3: deletedFileDuringRebaseConsideredAsRegularHunkWhenModifiedInDiff

import com.google.gerrit.extensions.common.DiffInfo; //導入依賴的package包/類
@Test
public void deletedFileDuringRebaseConsideredAsRegularHunkWhenModifiedInDiff() throws Exception {
  // Modify the file and revert the modifications to allow rebasing.
  addModifiedPatchSet(
      changeId, FILE_NAME, fileContent -> fileContent.replace("Line 50\n", "Line fifty\n"));
  String previousPatchSetId = gApi.changes().id(changeId).get().currentRevision;
  addModifiedPatchSet(
      changeId, FILE_NAME, fileContent -> fileContent.replace("Line fifty\n", "Line 50\n"));

  ObjectId commit2 = addCommitRemovingFiles(commit1, FILE_NAME);

  rebaseChangeOn(changeId, commit2);

  DiffInfo diffInfo =
      getDiffRequest(changeId, CURRENT, FILE_NAME).withBase(previousPatchSetId).get();
  assertThat(diffInfo).changeType().isEqualTo(ChangeType.DELETED);
  assertThat(diffInfo).content().element(0).linesOfA().hasSize(100);
  assertThat(diffInfo).content().element(0).linesOfB().isNull();
  assertThat(diffInfo).content().element(0).isNotDueToRebase();

  Map<String, FileInfo> changedFiles =
      gApi.changes().id(changeId).current().files(previousPatchSetId);
  assertThat(changedFiles.get(FILE_NAME)).linesInserted().isNull();
  assertThat(changedFiles.get(FILE_NAME)).linesDeleted().isEqualTo(100);
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:26,代碼來源:RevisionDiffIT.java

示例4: addedFileDuringRebaseConsideredAsRegularHunkWhenModifiedInDiff

import com.google.gerrit.extensions.common.DiffInfo; //導入依賴的package包/類
@Test
public void addedFileDuringRebaseConsideredAsRegularHunkWhenModifiedInDiff() throws Exception {
  String newFilePath = "a_new_file.txt";
  ObjectId commit2 = addCommit(commit1, newFilePath, "1st line\n2nd line\n3rd line\n");

  rebaseChangeOn(changeId, commit2);
  addModifiedPatchSet(
      changeId, newFilePath, fileContent -> fileContent.replace("1st line\n", "First line\n"));

  DiffInfo diffInfo =
      getDiffRequest(changeId, CURRENT, newFilePath).withBase(initialPatchSetId).get();
  assertThat(diffInfo).changeType().isEqualTo(ChangeType.ADDED);
  assertThat(diffInfo).content().element(0).linesOfA().isNull();
  assertThat(diffInfo).content().element(0).linesOfB().hasSize(3);
  assertThat(diffInfo).content().element(0).isNotDueToRebase();

  Map<String, FileInfo> changedFiles =
      gApi.changes().id(changeId).current().files(initialPatchSetId);
  assertThat(changedFiles.get(newFilePath)).linesInserted().isEqualTo(3);
  assertThat(changedFiles.get(newFilePath)).linesDeleted().isNull();
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:22,代碼來源:RevisionDiffIT.java

示例5: diff

import com.google.gerrit.extensions.common.DiffInfo; //導入依賴的package包/類
private DiffInfo diff(DiffRequest diffRequest) throws RestApiException {
    String query = "";

    if (!Strings.isNullOrEmpty(diffRequest.getBase())) {
        query = UrlUtils.appendToUrlQuery(query, "base=" + diffRequest.getBase());
    }
    if (diffRequest.getContext() != null) {
        query = UrlUtils.appendToUrlQuery(query, "context=" + diffRequest.getContext());
    }
    if (diffRequest.getIntraline() != null) {
        query = UrlUtils.appendToUrlQuery(query, "intraline=" + diffRequest.getIntraline());
    }
    if (diffRequest.getWhitespace() != null) {
        query = UrlUtils.appendToUrlQuery(query, "whitespace=" + diffRequest.getWhitespace());
    }

    String url = getRequestPath() +  "/diff";
    if (!Strings.isNullOrEmpty(query)) {
        url += '?' + query;
    }

    JsonElement jsonElement = gerritRestClient.getRequest(url);
    return diffInfoParser.parseDiffInfo(jsonElement);
}
 
開發者ID:uwolfer,項目名稱:gerrit-rest-java-client,代碼行數:25,代碼來源:FileApiRestClient.java

示例6: testDiff

import com.google.gerrit.extensions.common.DiffInfo; //導入依賴的package包/類
private void testDiff(Function<FileApiRestClient, Void> method, String expectedRequestUrl) throws Exception {
    JsonElement jsonElement = EasyMock.createMock(JsonElement.class);
    DiffInfo diffInfo = EasyMock.createMock(DiffInfo.class);

    DiffInfoParser diffInfoParser = EasyMock.createMock(DiffInfoParser.class);
    EasyMock.expect(diffInfoParser.parseDiffInfo(jsonElement)).andReturn(diffInfo).once();
    EasyMock.replay(diffInfoParser);

    setupServices();
    GerritRestClient gerritRestClient = new GerritRestClientBuilder().expectGet(expectedRequestUrl, jsonElement).get();

    FileApiRestClient fileApiRestClient = new FileApiRestClient(gerritRestClient, revisionApiRestClient, diffInfoParser, FILE_PATH);
    method.apply(fileApiRestClient);

    EasyMock.verify(gerritRestClient, diffInfoParser);
}
 
開發者ID:uwolfer,項目名稱:gerrit-rest-java-client,代碼行數:17,代碼來源:FileApiRestClientTest.java

示例7: assertDiffForNewFile

import com.google.gerrit.extensions.common.DiffInfo; //導入依賴的package包/類
protected void assertDiffForNewFile(
    DiffInfo diff, RevCommit commit, String path, String expectedContentSideB) throws Exception {
  List<String> expectedLines = new ArrayList<>();
  for (String line : expectedContentSideB.split("\n")) {
    expectedLines.add(line);
  }

  assertThat(diff.binary).isNull();
  assertThat(diff.changeType).isEqualTo(ChangeType.ADDED);
  assertThat(diff.diffHeader).isNotNull();
  assertThat(diff.intralineStatus).isNull();
  assertThat(diff.webLinks).isNull();

  assertThat(diff.metaA).isNull();
  assertThat(diff.metaB).isNotNull();
  assertThat(diff.metaB.commitId).isEqualTo(commit.name());

  String expectedContentType = "text/plain";
  if (COMMIT_MSG.equals(path)) {
    expectedContentType = FileContentUtil.TEXT_X_GERRIT_COMMIT_MESSAGE;
  } else if (MERGE_LIST.equals(path)) {
    expectedContentType = FileContentUtil.TEXT_X_GERRIT_MERGE_LIST;
  }
  assertThat(diff.metaB.contentType).isEqualTo(expectedContentType);

  assertThat(diff.metaB.lines).isEqualTo(expectedLines.size());
  assertThat(diff.metaB.name).isEqualTo(path);
  assertThat(diff.metaB.webLinks).isNull();

  assertThat(diff.content).hasSize(1);
  DiffInfo.ContentEntry contentEntry = diff.content.get(0);
  assertThat(contentEntry.b).containsExactlyElementsIn(expectedLines).inOrder();
  assertThat(contentEntry.a).isNull();
  assertThat(contentEntry.ab).isNull();
  assertThat(contentEntry.common).isNull();
  assertThat(contentEntry.editA).isNull();
  assertThat(contentEntry.editB).isNull();
  assertThat(contentEntry.skip).isNull();
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:40,代碼來源:AbstractDaemonTest.java

示例8: diff

import com.google.gerrit.extensions.common.DiffInfo; //導入依賴的package包/類
@Override
public DiffInfo diff() throws RestApiException {
  try {
    return getDiff.apply(file).value();
  } catch (Exception e) {
    throw asRestApiException("Cannot retrieve diff", e);
  }
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:9,代碼來源:FileApiImpl.java

示例9: diffRequest

import com.google.gerrit.extensions.common.DiffInfo; //導入依賴的package包/類
@Override
public DiffRequest diffRequest() {
  return new DiffRequest() {
    @Override
    public DiffInfo get() throws RestApiException {
      return FileApiImpl.this.get(this);
    }
  };
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:10,代碼來源:FileApiImpl.java

示例10: diffDeletedFile

import com.google.gerrit.extensions.common.DiffInfo; //導入依賴的package包/類
@Test
public void diffDeletedFile() throws Exception {
  gApi.changes().id(changeId).edit().deleteFile(FILE_NAME);
  gApi.changes().id(changeId).edit().publish();

  Map<String, FileInfo> changedFiles = gApi.changes().id(changeId).current().files();
  assertThat(changedFiles.keySet()).containsExactly(COMMIT_MSG, FILE_NAME);

  DiffInfo diff = getDiffRequest(changeId, CURRENT, FILE_NAME).get();
  assertThat(diff.metaA.lines).isEqualTo(100);
  assertThat(diff.metaB).isNull();
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:13,代碼來源:RevisionDiffIT.java

示例11: rebaseHunksAtStartOfFileAreIdentified

import com.google.gerrit.extensions.common.DiffInfo; //導入依賴的package包/類
@Test
public void rebaseHunksAtStartOfFileAreIdentified() throws Exception {
  String newFileContent =
      FILE_CONTENT.replace("Line 1\n", "Line one\n").replace("Line 5\n", "Line five\n");
  ObjectId commit2 = addCommit(commit1, FILE_NAME, newFileContent);

  rebaseChangeOn(changeId, commit2);
  Function<String, String> contentModification =
      fileContent -> fileContent.replace("Line 50\n", "Line fifty\n");
  addModifiedPatchSet(changeId, FILE_NAME, contentModification);

  DiffInfo diffInfo =
      getDiffRequest(changeId, CURRENT, FILE_NAME).withBase(initialPatchSetId).get();
  assertThat(diffInfo).content().element(0).linesOfA().containsExactly("Line 1");
  assertThat(diffInfo).content().element(0).linesOfB().containsExactly("Line one");
  assertThat(diffInfo).content().element(0).isDueToRebase();
  assertThat(diffInfo).content().element(1).commonLines().hasSize(3);
  assertThat(diffInfo).content().element(2).linesOfA().containsExactly("Line 5");
  assertThat(diffInfo).content().element(2).linesOfB().containsExactly("Line five");
  assertThat(diffInfo).content().element(2).isDueToRebase();
  assertThat(diffInfo).content().element(3).commonLines().hasSize(44);
  assertThat(diffInfo).content().element(4).linesOfA().containsExactly("Line 50");
  assertThat(diffInfo).content().element(4).linesOfB().containsExactly("Line fifty");
  assertThat(diffInfo).content().element(4).isNotDueToRebase();
  assertThat(diffInfo).content().element(5).commonLines().hasSize(50);

  Map<String, FileInfo> changedFiles =
      gApi.changes().id(changeId).current().files(initialPatchSetId);
  assertThat(changedFiles.get(FILE_NAME)).linesInserted().isEqualTo(1);
  assertThat(changedFiles.get(FILE_NAME)).linesDeleted().isEqualTo(1);
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:32,代碼來源:RevisionDiffIT.java

示例12: rebaseHunksAtEndOfFileAreIdentified

import com.google.gerrit.extensions.common.DiffInfo; //導入依賴的package包/類
@Test
public void rebaseHunksAtEndOfFileAreIdentified() throws Exception {
  String newFileContent =
      FILE_CONTENT
          .replace("Line 60\n", "Line sixty\n")
          .replace("Line 100\n", "Line one hundred\n");
  ObjectId commit2 = addCommit(commit1, FILE_NAME, newFileContent);

  rebaseChangeOn(changeId, commit2);
  Function<String, String> contentModification =
      fileContent -> fileContent.replace("Line 50\n", "Line fifty\n");
  addModifiedPatchSet(changeId, FILE_NAME, contentModification);

  DiffInfo diffInfo =
      getDiffRequest(changeId, CURRENT, FILE_NAME).withBase(initialPatchSetId).get();
  assertThat(diffInfo).content().element(0).commonLines().hasSize(49);
  assertThat(diffInfo).content().element(1).linesOfA().containsExactly("Line 50");
  assertThat(diffInfo).content().element(1).linesOfB().containsExactly("Line fifty");
  assertThat(diffInfo).content().element(1).isNotDueToRebase();
  assertThat(diffInfo).content().element(2).commonLines().hasSize(9);
  assertThat(diffInfo).content().element(3).linesOfA().containsExactly("Line 60");
  assertThat(diffInfo).content().element(3).linesOfB().containsExactly("Line sixty");
  assertThat(diffInfo).content().element(3).isDueToRebase();
  assertThat(diffInfo).content().element(4).commonLines().hasSize(39);
  assertThat(diffInfo).content().element(5).linesOfA().containsExactly("Line 100");
  assertThat(diffInfo).content().element(5).linesOfB().containsExactly("Line one hundred");
  assertThat(diffInfo).content().element(5).isDueToRebase();

  Map<String, FileInfo> changedFiles =
      gApi.changes().id(changeId).current().files(initialPatchSetId);
  assertThat(changedFiles.get(FILE_NAME)).linesInserted().isEqualTo(1);
  assertThat(changedFiles.get(FILE_NAME)).linesDeleted().isEqualTo(1);
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:34,代碼來源:RevisionDiffIT.java

示例13: rebaseHunksInBetweenRegularHunksAreIdentified

import com.google.gerrit.extensions.common.DiffInfo; //導入依賴的package包/類
@Test
public void rebaseHunksInBetweenRegularHunksAreIdentified() throws Exception {
  String newFileContent =
      FILE_CONTENT.replace("Line 40\n", "Line forty\n").replace("Line 45\n", "Line forty five\n");
  ObjectId commit2 = addCommit(commit1, FILE_NAME, newFileContent);

  rebaseChangeOn(changeId, commit2);
  Function<String, String> contentModification =
      fileContent ->
          fileContent
              .replace("Line 1\n", "Line one\n")
              .replace("Line 100\n", "Line one hundred\n");
  addModifiedPatchSet(changeId, FILE_NAME, contentModification);

  DiffInfo diffInfo =
      getDiffRequest(changeId, CURRENT, FILE_NAME).withBase(initialPatchSetId).get();
  assertThat(diffInfo).content().element(0).linesOfA().containsExactly("Line 1");
  assertThat(diffInfo).content().element(0).linesOfB().containsExactly("Line one");
  assertThat(diffInfo).content().element(0).isNotDueToRebase();
  assertThat(diffInfo).content().element(1).commonLines().hasSize(38);
  assertThat(diffInfo).content().element(2).linesOfA().containsExactly("Line 40");
  assertThat(diffInfo).content().element(2).linesOfB().containsExactly("Line forty");
  assertThat(diffInfo).content().element(2).isDueToRebase();
  assertThat(diffInfo).content().element(3).commonLines().hasSize(4);
  assertThat(diffInfo).content().element(4).linesOfA().containsExactly("Line 45");
  assertThat(diffInfo).content().element(4).linesOfB().containsExactly("Line forty five");
  assertThat(diffInfo).content().element(4).isDueToRebase();
  assertThat(diffInfo).content().element(5).commonLines().hasSize(54);
  assertThat(diffInfo).content().element(6).linesOfA().containsExactly("Line 100");
  assertThat(diffInfo).content().element(6).linesOfB().containsExactly("Line one hundred");
  assertThat(diffInfo).content().element(6).isNotDueToRebase();

  Map<String, FileInfo> changedFiles =
      gApi.changes().id(changeId).current().files(initialPatchSetId);
  assertThat(changedFiles.get(FILE_NAME)).linesInserted().isEqualTo(2);
  assertThat(changedFiles.get(FILE_NAME)).linesDeleted().isEqualTo(2);
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:38,代碼來源:RevisionDiffIT.java

示例14: rebaseHunkIsIdentifiedWhenMovedDownInPreviousPatchSet

import com.google.gerrit.extensions.common.DiffInfo; //導入依賴的package包/類
@Test
public void rebaseHunkIsIdentifiedWhenMovedDownInPreviousPatchSet() throws Exception {
  // Move the code down by introducing additional lines (pure insert + enlarging replacement) in
  // the previous patch set.
  Function<String, String> contentModification1 =
      fileContent ->
          "Line zero\n" + fileContent.replace("Line 10\n", "Line ten\nLine ten and a half\n");
  addModifiedPatchSet(changeId, FILE_NAME, contentModification1);
  String previousPatchSetId = gApi.changes().id(changeId).get().currentRevision;

  String newFileContent = FILE_CONTENT.replace("Line 40\n", "Line forty\n");
  ObjectId commit2 = addCommit(commit1, FILE_NAME, newFileContent);

  rebaseChangeOn(changeId, commit2);
  Function<String, String> contentModification2 =
      fileContent -> fileContent.replace("Line 100\n", "Line one hundred\n");
  addModifiedPatchSet(changeId, FILE_NAME, contentModification2);

  DiffInfo diffInfo =
      getDiffRequest(changeId, CURRENT, FILE_NAME).withBase(previousPatchSetId).get();
  assertThat(diffInfo).content().element(0).commonLines().hasSize(41);
  assertThat(diffInfo).content().element(1).linesOfA().containsExactly("Line 40");
  assertThat(diffInfo).content().element(1).linesOfB().containsExactly("Line forty");
  assertThat(diffInfo).content().element(1).isDueToRebase();
  assertThat(diffInfo).content().element(2).commonLines().hasSize(59);
  assertThat(diffInfo).content().element(3).linesOfA().containsExactly("Line 100");
  assertThat(diffInfo).content().element(3).linesOfB().containsExactly("Line one hundred");
  assertThat(diffInfo).content().element(3).isNotDueToRebase();

  Map<String, FileInfo> changedFiles =
      gApi.changes().id(changeId).current().files(previousPatchSetId);
  assertThat(changedFiles.get(FILE_NAME)).linesInserted().isEqualTo(1);
  assertThat(changedFiles.get(FILE_NAME)).linesDeleted().isEqualTo(1);
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:35,代碼來源:RevisionDiffIT.java

示例15: rebaseHunkIsIdentifiedWhenMovedDownInLatestPatchSet

import com.google.gerrit.extensions.common.DiffInfo; //導入依賴的package包/類
@Test
public void rebaseHunkIsIdentifiedWhenMovedDownInLatestPatchSet() throws Exception {
  String newFileContent = FILE_CONTENT.replace("Line 40\n", "Line forty\n");
  ObjectId commit2 = addCommit(commit1, FILE_NAME, newFileContent);

  rebaseChangeOn(changeId, commit2);
  // Move the code down by introducing additional lines (pure insert + enlarging replacement) in
  // the latest patch set.
  Function<String, String> contentModification =
      fileContent ->
          "Line zero\n" + fileContent.replace("Line 10\n", "Line ten\nLine ten and a half\n");
  addModifiedPatchSet(changeId, FILE_NAME, contentModification);

  DiffInfo diffInfo =
      getDiffRequest(changeId, CURRENT, FILE_NAME).withBase(initialPatchSetId).get();
  assertThat(diffInfo).content().element(0).linesOfA().isNull();
  assertThat(diffInfo).content().element(0).linesOfB().containsExactly("Line zero");
  assertThat(diffInfo).content().element(0).isNotDueToRebase();
  assertThat(diffInfo).content().element(1).commonLines().hasSize(9);
  assertThat(diffInfo).content().element(2).linesOfA().containsExactly("Line 10");
  assertThat(diffInfo)
      .content()
      .element(2)
      .linesOfB()
      .containsExactly("Line ten", "Line ten and a half");
  assertThat(diffInfo).content().element(2).isNotDueToRebase();
  assertThat(diffInfo).content().element(3).commonLines().hasSize(29);
  assertThat(diffInfo).content().element(4).linesOfA().containsExactly("Line 40");
  assertThat(diffInfo).content().element(4).linesOfB().containsExactly("Line forty");
  assertThat(diffInfo).content().element(4).isDueToRebase();
  assertThat(diffInfo).content().element(5).commonLines().hasSize(60);

  Map<String, FileInfo> changedFiles =
      gApi.changes().id(changeId).current().files(initialPatchSetId);
  assertThat(changedFiles.get(FILE_NAME)).linesInserted().isEqualTo(3);
  assertThat(changedFiles.get(FILE_NAME)).linesDeleted().isEqualTo(1);
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:38,代碼來源:RevisionDiffIT.java


注:本文中的com.google.gerrit.extensions.common.DiffInfo類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。