Package org.eclipse.jgit.diff

Examples of org.eclipse.jgit.diff.RawText$Factory


  }

  private static RawText getRawText(ObjectId id, Repository db)
      throws IOException {
    if (id.equals(ObjectId.zeroId()))
      return new RawText(new byte[] {});
    return new RawText(db.open(id, Constants.OBJ_BLOB).getCachedBytes());
  }
View Full Code Here


        MergeResult<RawText> mergeResult;
        try
        {
            mergeResult = mergeAlgorithm.merge(
                    RawTextComparator.DEFAULT,
                    new RawText(base.getBytes(charsetName)),
                    new RawText(generated.getBytes(charsetName)),
                    new RawText(edited.getBytes(charsetName)));
        }
        catch (UnsupportedEncodingException e)
        {
            throw new GeneratorException(
                    "unknown character set " + charsetName,
View Full Code Here

     * @return the diff
     * @throws IOException Signals that an I/O exception has occurred.
     */
    private String getDiffinGitFormat(String string1, String string2) throws IOException {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        RawText rt1 = new RawText(string1.getBytes());
        RawText rt2 = new RawText(string2.getBytes());
        EditList diffList = new EditList();
        diffList.addAll(new HistogramDiff().diff(RawTextComparator.DEFAULT, rt1, rt2));
        new DiffFormatter(out).format(diffList, rt1, rt2);
        return out.toString();
    }
View Full Code Here

public class FileDiffTest {
    @Test
    public void getHunks() throws IOException {
        // given
        FileDiff fileDiff = new FileDiff();
        fileDiff.a = new RawText("apple\nbanana\ncat\n".getBytes());
        fileDiff.b = new RawText("apple\nbanana\ncorn\n".getBytes());
        DiffAlgorithm diffAlgorithm =
                DiffAlgorithm.getAlgorithm(DiffAlgorithm.SupportedAlgorithm.HISTOGRAM);
        fileDiff.editList = diffAlgorithm.diff(RawTextComparator.DEFAULT, fileDiff.a,
                        fileDiff.b);
View Full Code Here

   * @throws IOException
   * @throws PatchApplyException
   */
  private void apply(File f, FileHeader fh)
      throws IOException, PatchApplyException {
    RawText rt = new RawText(f);
    List<String> oldLines = new ArrayList<String>(rt.size());
    for (int i = 0; i < rt.size(); i++)
      oldLines.add(rt.getString(i));
    List<String> newLines = new ArrayList<String>(oldLines);
    for (HunkHeader hh : fh.getHunks()) {
      StringBuilder hunk = new StringBuilder();
      for (int j = hh.getStartOffset(); j < hh.getEndOffset(); j++)
        hunk.append((char) hh.getBuffer()[j]);
      RawText hrt = new RawText(hunk.toString().getBytes());
      List<String> hunkLines = new ArrayList<String>(hrt.size());
      for (int i = 0; i < hrt.size(); i++)
        hunkLines.add(hrt.getString(i));
      int pos = 0;
      for (int j = 1; j < hunkLines.size(); j++) {
        String hunkLine = hunkLines.get(j);
        switch (hunkLine.charAt(0)) {
        case ' ':
View Full Code Here

    return false;
  }

  private boolean isNoNewlineAtEndOfFile(FileHeader fh) {
    HunkHeader lastHunk = fh.getHunks().get(fh.getHunks().size() - 1);
    RawText lhrt = new RawText(lastHunk.getBuffer());
    return lhrt.getString(lhrt.size() - 1).equals(
        "\\ No newline at end of file"); //$NON-NLS-1$
  }
View Full Code Here

   * @throws IOException
   *             the repository cannot be read.
   */
  public BlameGenerator push(String description, byte[] contents)
      throws IOException {
    return push(description, new RawText(contents));
  }
View Full Code Here

    if (ldr.getType() == OBJ_BLOB) {
      if (description == null)
        description = JGitText.get().blameNotCommittedYet;
      BlobCandidate c = new BlobCandidate(description, resultPath);
      c.sourceBlob = id.toObjectId();
      c.sourceText = new RawText(ldr.getCachedBytes(Integer.MAX_VALUE));
      c.regionList = new Region(0, 0, c.sourceText.size());
      remaining = c.sourceText.size();
      push(c);
      return this;
    }
View Full Code Here

   * @throws IOException
   */
  private MergeResult<RawText> contentMerge(CanonicalTreeParser base,
      CanonicalTreeParser ours, CanonicalTreeParser theirs)
      throws IOException {
    RawText baseText = base == null ? RawText.EMPTY_TEXT : getRawText(
        base.getEntryObjectId(), db);
    RawText ourText = ours == null ? RawText.EMPTY_TEXT : getRawText(
        ours.getEntryObjectId(), db);
    RawText theirsText = theirs == null ? RawText.EMPTY_TEXT : getRawText(
        theirs.getEntryObjectId(), db);
    return (mergeAlgorithm.merge(RawTextComparator.DEFAULT, baseText,
        ourText, theirsText));
  }
View Full Code Here

  }

  private static RawText getRawText(ObjectId id, Repository db)
      throws IOException {
    if (id.equals(ObjectId.zeroId()))
      return new RawText(new byte[] {});
    return new RawText(db.open(id, Constants.OBJ_BLOB).getCachedBytes());
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.diff.RawText$Factory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.