Package org.apache.commons.jrcs.diff

Examples of org.apache.commons.jrcs.diff.Revision


    getSourceViewer().getTextWidget().setRedraw(false);
   
    String[] text1 = doc.get().split("\n");
    String[] text2 = text.split("\n");
    try {
      Revision rev = Diff.diff(text1,text2);
      int count1 = 0;
      int count2 = 0;
      int index  = 0;
      for(int i=0;i<rev.size();i++){
        Delta delta = rev.getDelta(i);
        Range orgRange = new Range(delta.getOriginal().rangeString());
        Range revRange = new Range(delta.getRevised().rangeString());
        // matched
        while(count1!=orgRange.getFrom()-1){
          index = index + text1[count1].length() + 1;
View Full Code Here


    getSourceViewer().getTextWidget().setRedraw(false);

    String[] text1 = doc.get().split("\n");
    String[] text2 = text.split("\n");
    try {
      Revision rev = Diff.diff(text1, text2);
      int count1 = 0;
      int count2 = 0;
      int index = 0;
      for (int i = 0; i < rev.size(); i++) {
        Delta delta = rev.getDelta(i);
        Range orgRange = new Range(delta.getOriginal().rangeString());
        Range revRange = new Range(delta.getRevised().rangeString());
        // matched
        while (count1 != orgRange.getFrom() - 1) {
          index = index + text1[count1].length() + 1;
View Full Code Here

        {
            Object[] orig = loadFile(argv[0]);
            Object[] rev = loadFile(argv[1]);

            Diff df = new Diff(orig);
            Revision r = df.diff(rev);

            System.err.println("------");
            System.out.print(r.toString());
            System.err.println("------" + new Date());

            try
            {
                Object[] reco = r.patch(orig);
                //String recos = Diff.arrayToString(reco);
                if (!Diff.compare(rev, reco))
                {
                    System.err.println("INTERNAL ERROR:"
                                        + "files differ after patching!");
View Full Code Here

     */
    public void patch(List original, boolean annotate)
            throws InvalidFileFormatException,
            org.apache.commons.jrcs.diff.PatchFailedException
    {
        Revision revision = new Revision();
        for (int it = 0; it < text.length; it++)
        {
            String cmd = text[it].toString();

            java.util.StringTokenizer t = new StringTokenizer(cmd, "ad ", true);
            char action;
            int n;
            int count;

            try
            {
                action = t.nextToken().charAt(0);
                n = Integer.parseInt(t.nextToken());
                t.nextToken();    // skip the space
                count = Integer.parseInt(t.nextToken());
            }
            catch (Exception e)
            {
                throw new InvalidFileFormatException(version + ":line:" + ":" + e.getMessage());
            }

            if (action == 'd')
            {
                revision.addDelta(new DeleteDelta(new Chunk(n - 1, count)));
            }
            else if (action == 'a')
            {
                revision.addDelta(new AddDelta(n, new Chunk(getTextLines(it + 1, it + 1 + count), 0, count, n - 1)));
                it += count;
            }
            else
            {
                throw new InvalidFileFormatException(version.toString());
            }
        }
        revision.applyTo(original);
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.jrcs.diff.Revision

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.