Package org.eclipse.jgit.diff

Examples of org.eclipse.jgit.diff.RawText


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


  }

  private static RawText getRawText(ObjectId id, ObjectReader reader)
      throws IOException {
    if (id.equals(ObjectId.zeroId()))
      return new RawText(new byte[] {});
    return new RawText(reader.open(id, OBJ_BLOB).getCachedBytes());
  }
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

          if (0 <= entry)
            gen.push(null, dc.getEntry(entry).getObjectId());

          File inTree = new File(repo.getWorkTree(), path);
          if (repo.getFS().isFile(inTree)) {
            RawText rawText = getRawText(inTree);
            gen.push(null, rawText);
          }
        }
      }
      return gen.computeBlameResult();
View Full Code Here

    }
  }

  private RawText getRawText(File inTree) throws IOException,
      FileNotFoundException {
    RawText rawText;

    WorkingTreeOptions workingTreeOptions = getRepository().getConfig()
        .get(WorkingTreeOptions.KEY);
    AutoCRLF autoCRLF = workingTreeOptions.getAutoCRLF();
    switch (autoCRLF) {
    case FALSE:
    case INPUT:
      // Git used the repo format on checkout, but other tools
      // may change the format to CRLF. We ignore that here.
      rawText = new RawText(inTree);
      break;
    case TRUE:
      EolCanonicalizingInputStream in = new EolCanonicalizingInputStream(
          new FileInputStream(inTree), true);
      // Canonicalization should lead to same or shorter length
      // (CRLF to LF), so the file size on disk is an upper size bound
      rawText = new RawText(toByteArray(in, (int) inTree.length()));
      break;
    default:
      throw new IllegalArgumentException(
          "Unknown autocrlf option " + autoCRLF); //$NON-NLS-1$
    }
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

    }
    return r.toString();
  }

  public static RawText T(String text) {
    return new RawText(Constants.encode(t(text)));
  }
View Full Code Here

            continue;
          }
          if (RawText.isBinary(raw1))
            continue;

          RawText txt0 = new RawText(raw0);
          RawText txt1 = new RawText(raw1);

          minN = Math.min(minN, txt0.size() + txt1.size());
          maxN = Math.max(maxN, txt0.size() + txt1.size());

          for (Test test : all)
            testOne(test, txt0, txt1);
          files++;
        }
View Full Code Here

TOP

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

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.