Package difflib

Examples of difflib.Patch


        String oldContent = getDriftFileBits(subject, drift.getOldDriftFile().getHashId());
        List<String> oldList = asList(oldContent.split("\\n"));
        String newContent = getDriftFileBits(subject, drift.getNewDriftFile().getHashId());
        List<String> newList = asList(newContent.split("\\n"));

        Patch patch = DiffUtils.diff(oldList, newList);
        List<String> deltas = DiffUtils.generateUnifiedDiff(drift.getPath(), drift.getPath(), oldList, patch, 10);

        return new FileDiffReport(patch.getDeltas().size(), deltas);
    }
View Full Code Here


        DriftFile drift2File = drift2.getNewDriftFile();
        String content2 = (null == drift2File) ? "" : getDriftFileBits(subject, drift2File.getHashId());
        List<String> content2List = asList(content2.split("\\n"));

        Patch patch = DiffUtils.diff(content1List, content2List);
        List<String> deltas = DiffUtils
            .generateUnifiedDiff(drift1.getPath(), drift2.getPath(), content1List, patch, 10);

        return new FileDiffReport(patch.getDeltas().size(), deltas);
    }
View Full Code Here

        List<String> actualList = asList(actualContents.split("\\n"));

        String expectedContents = StreamUtil.slurp(new FileReader(expectedFile));
        List<String> expectedList = asList(expectedContents.split("\\n"));

        Patch patch = DiffUtils.diff(actualList, expectedList);
        List<String> diffs = DiffUtils.generateUnifiedDiff(actualFile.getName(), "expected.cassandra.yaml", actualList,
            patch, 5);
        assertTrue(patch.getDeltas().isEmpty(), actualFile.getName() + " was not configured correctly. The "
            + "following differences were found:\n" + StringUtil.listToString(diffs, "\n"));
    }
View Full Code Here

          else {
            //andTrueBodyOutput[booleanStrippedUnstrippedIndex].compareTo(normalBodyOutput[booleanStrippedUnstrippedIndex])
            //the results of the "AND 1=1" do NOT match the original query, for whatever reason (no sql injection, or the web page is not stable)
            if (this.debugEnabled) {
              log.debug("Check 2, " + (strippedOutput[booleanStrippedUnstrippedIndex] ? "STRIPPED" : "UNSTRIPPED") + " html output for AND condition [" + sqlBooleanAndTrueValue + "] does NOT match the (refreshed) original results for " + refreshedmessage.getRequestHeader().getURI());
              Patch diffpatch = DiffUtils.diff(
                  new LinkedList<String>(Arrays.asList(normalBodyOutput[booleanStrippedUnstrippedIndex].split("\\n"))),
                  new LinkedList<String>(Arrays.asList(andTrueBodyOutput[booleanStrippedUnstrippedIndex].split("\\n"))));

              //int numberofDifferences = diffpatch.getDeltas().size();

              //and convert the list of patches to a String, joining using a newline
              StringBuilder tempDiff = new StringBuilder(250);
              for (Delta delta : diffpatch.getDeltas()) {
                String changeType = null;
                if (delta.getType() == Delta.TYPE.CHANGE) {
                  changeType = "Changed Text";
                } else if (delta.getType() == Delta.TYPE.DELETE) {
                  changeType = "Deleted Text";
View Full Code Here

        List<String> oldLines = Lists.newArrayList(splitter.split(oldDiff));
        List<String> newLines = Lists.newArrayList(splitter.split(newDiff));
        if (oldLines.equals(newLines)) {
            return "";
        }
        Patch diffs = DiffUtils.diff(oldLines, newLines);
        return Joiner.on("\n").join(DiffUtils.generateUnifiedDiff(DIFF_OLD_FILE_NAME, DIFF_NEW_FILE_NAME, oldLines,
                diffs, DIFF_CONTEXT_LINES));
    }
View Full Code Here

  /**
   * �����擾���������s���܂��B
   */
  public void doDiff() {

    Patch rev = DiffUtils.diff(this.text1, this.text2);

    int count1 = 0;
    int count2 = 0;

    for (Delta delta : rev.getDeltas()) {
      Chunk orgChunk = delta.getOriginal();
      Chunk revChunk = delta.getRevised();

      while (count1 != orgChunk.getPosition()) {
        this.handler.match(this.text1.get(count1));
View Full Code Here

    }
    return matches;
  }

  private List<Delta> getDeltas() {
    Patch diff = DiffUtils.diff(oldMatches, newMatches);
    return diff.getDeltas();
  }
View Full Code Here

public class VersionComparer {

  private List<String> differences;
 
  public boolean compare(String originalVersion, String originalContent, String revisedVersion, String revisedContent) {
    Patch patch = DiffUtils.diff(contentToLines(originalContent), contentToLines(revisedContent));
    differences = DiffUtils.generateUnifiedDiff(originalVersion, revisedVersion,
        contentToLines(originalContent), patch, 5);
    return true;
  }
View Full Code Here

        } catch (IOException e) {
            TestUtils.getLog().println("Unable to break up output into lines");
            e.printStackTrace();
        }

        Patch diff = DiffUtils.diff(referenceLines, outputLines);

        if (!diff.getDeltas().isEmpty()) {
            TestUtils.getLog().println("Reference output diff:");
            List<String> diffOutput = DiffUtils.generateUnifiedDiff(fileName + ".css", fileName + ".css", referenceLines, diff, 3);
            for (String diffOutputLine : diffOutput) {
                TestUtils.getLog().println(diffOutputLine);
            }
        }

        Assert.assertEquals(diff.getDeltas().size(), 0);
    }
View Full Code Here

            path = buildPath(orig, rev);
            return buildRevision(path, orig, rev);
        } catch (DifferentiationFailedException e) {
            e.printStackTrace();
        }
        return new Patch();
    }
View Full Code Here

TOP

Related Classes of difflib.Patch

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.