You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jv...@apache.org on 2002/02/20 17:20:04 UTC
cvs commit: jakarta-turbine-maven/src/test/org/apache/maven/jrcs/rcs ArchiveTest.java
jvanzyl 02/02/20 08:20:04
Modified: . build.xml default.properties
Added: src/java/org/apache/maven/jrcs jdiff.java rcsp.java
src/java/org/apache/maven/jrcs/diff AddDelta.java
ChangeDelta.java Chunk.java DeleteDelta.java
Delta.java Diff.java DiffException.java
DifferentiationFailedException.java
PatchFailedException.java Range.java Revision.java
src/java/org/apache/maven/jrcs/rcs
ASCII_UCodeESC_CharStream.java Archive.java
ArchiveParser.java ArchiveParserConstants.java
ArchiveParserTokenManager.java BranchNode.java
BranchNotFoundException.java
HeadAlreadySetException.java
InvalidBranchVersionNumberException.java
InvalidFileFormatException.java
InvalidTrunkVersionNumberException.java
InvalidVersionNumberException.java Line.java
Lines.java Node.java NodeNotFoundException.java
ParseException.java Path.java Phrases.java
RCSException.java Token.java TokenMgrError.java
TrunkNode.java Version.java
src/java/org/apache/maven/jrcs/util ToString.java
src/test/org/apache/maven/jrcs/diff DiffTest.java
src/test/org/apache/maven/jrcs/rcs ArchiveTest.java
Log:
- adding Jauncarlo Arnez's Javacc based RCS ,v file parser. it currently uses
the GNU regex package which is LGPL (Jaun, I thought it was GPL) so it's ok
but Jaun will switch over to the Jakarta package. I just wanted to get this
in CVS so Jaun could work on it from here after I swapped the package and
license statements.
Revision Changes Path
1.5 +1 -0 jakarta-turbine-maven/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/build.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- build.xml 20 Feb 2002 08:11:13 -0000 1.4
+++ build.xml 20 Feb 2002 16:20:02 -0000 1.5
@@ -22,6 +22,7 @@
<pathelement location="${oro.jar}"/>
<pathelement location="${dvsl.jar}" />
<pathelement location="${dom4j.jar}" />
+ <pathelement location="${gnu.regex.jar}" />
</path>
<!-- ================================================================== -->
1.4 +1 -0 jakarta-turbine-maven/default.properties
Index: default.properties
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/default.properties,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- default.properties 20 Feb 2002 08:11:13 -0000 1.3
+++ default.properties 20 Feb 2002 16:20:02 -0000 1.4
@@ -47,6 +47,7 @@
commons-collections.jar = ${lib.repo}/commons-collections.jar
commons-graph.jar = ${lib.repo}/commons-graph.jar
oro.jar = ${lib.repo}/oro.jar
+gnu.regex.jar = ${lib.repo}/gnu-regexp-1.1.4.jar
workspace = src/descriptors/workspace/jvz.xml
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/jdiff.java
Index: jdiff.java
===================================================================
package org.apache.maven.jrcs;
import java.util.*;
import java.io.*;
import org.apache.maven.jrcs.diff.*;
public class jdiff {
static final String[] loadFile(String name) throws IOException
{
BufferedReader data = new BufferedReader(new FileReader(name));
Vector v = new Vector();
String s;
while ((s = data.readLine()) != null)
v.addElement(s);
String[] result = new String[v.size()];
v.copyInto(result);
return result;
}
static final void ussage(String name) {
System.err.println("Ussage: " + name + " file1 file2");
}
public static void main(String[] argv) throws Exception
{
if (argv.length < 2)
ussage("jdiff");
else {
Object[] orig = loadFile(argv[0]);
Object[] rev = loadFile(argv[1]);
System.err.println("---go!----");
Diff df = new Diff(orig);
Revision r = df.diff(rev);
System.err.println("---end!---");
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("**********");
System.err.print(Diff.arrayToString(rev));
System.err.println("**********");
System.err.print(recos);
System.err.println("**********");
*/
System.err.println("files differ");
}
}
catch(Throwable o) {
System.out.println("Patch failed");
}
}
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcsp.java
Index: rcsp.java
===================================================================
package org.apache.maven.jrcs;
import org.apache.maven.jrcs.rcs.*;
import org.apache.maven.jrcs.diff.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
public class rcsp {
static Archive arc;
static Object[] orig;
static public void main(String[] args) throws Exception {
// try {
if (args.length > 2)
System.out.println("WRONG USSAGE: need at most one parameter");
else {
if (args.length >= 1)
arc = new Archive(args[0]);
else
arc = new Archive("test,v",System.in);
System.err.println();
System.err.println("==========================================");
//System.out.println(arc.toString());
//System.out.println(arc.getRevision("5.2.7.1"));
//System.out.println(arc.getRevision(args[1], true));
//arc.addRevision(new Object[]{}, args[1]);
orig = arc.getRevision("1.3");
System.out.println("*-orig-*********");
System.out.print(Diff.arrayToString(orig));
System.out.println("**********");
Object[] other = arc.getRevision("1.2");
//!! commented out because of package access error (jvz).
//System.out.println(Diff.diff(arc.removeKeywords(orig), arc.removeKeywords(other)).toRCSString());
trywith("1.2.3.1");
trywith("1.2.3.5");
trywith("1.2.3.1.");
trywith("1.2");
trywith("1.2.2");
/*
trywith("1.2.2.2");
trywith("1.2.2.1.1");
trywith("1.2.2");
trywith("1.2.3");
trywith("1.2.3");
*/
}
/* }
catch(java.io.IOException e) {
System.out.println(e.getClass().toString());
System.out.println(e.getMessage());
e.printStackTrace();
}
*/
}
static String edited =
" *\n"+
" * This software is distributed under the GNU General Public License.\n"+
" * See the file COPYING.TXT for details.\n"+
"randomEdit[1][0]\n"+
"randomEdit[1][2]";
static int n = 1;
static void trywith(String ver) {
try {
System.out.println();
System.out.println("-------------");
System.out.println("Adding "+ ver);
/*
List editor = new ArrayList(Arrays.asList(orig));
editor.subList(0,1).clear();
editor.add(0, "hola!");
Object[] rev = editor.toArray();
*/
Object[] rev = Diff.randomEdit(orig, n++);
//rev = Diff.stringToArray(arc.doKeywords(Diff.arrayToString(rev), null));
//System.out.print(Archive.arrayToString(rev));
Version newVer = arc.addRevision(rev, ver);
System.out.println( newVer + " added");
if (newVer != null) {
Object[] rec = arc.getRevision(newVer);
//System.out.print(Archive.arrayToString(rec));
/* !! commented out because of package access errors (jvz).
if (!Diff.compare(arc.removeKeywords(rec), arc.removeKeywords(rev))) {
System.out.println("revisions differ!");
System.out.println("**********");
System.out.println(Diff.arrayToString(rec));
System.out.println("**********");
System.out.println(Diff.arrayToString(rev));
System.out.println("**********");
System.out.print(Diff.diff(rec, rev).toRCSString());
System.out.println("**********");
}
*/
}
System.out.println(ver + " OK");
} catch(Exception e) {
System.err.println(e.getMessage());
e.printStackTrace();
}
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/AddDelta.java
Index: AddDelta.java
===================================================================
package org.apache.maven.jrcs.diff;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import java.util.List;
public class AddDelta extends Delta {
AddDelta() {
super();
}
public AddDelta(int origpos, Chunk rev) {
init(new Chunk(origpos, 0), rev);
}
public void verify(List target) throws PatchFailedException {
if (original.first() > target.size())
throw new PatchFailedException("original.first() > target.size()");
}
public void applyTo(List target) {
revised.applyAdd(original.first(), target);
}
public void toString(StringBuffer s) {
s.append(original.anchor());
s.append("a");
s.append(revised.range());
s.append(Diff.NL);
revised.toString(s, "> ", Diff.NL);
}
public void toRCSString(StringBuffer s, String EOL) {
s.append("a");
s.append(original.anchor());
s.append(" ");
s.append(revised.range().length());
s.append(EOL);
revised.toString(s, "", EOL);
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/ChangeDelta.java
Index: ChangeDelta.java
===================================================================
package org.apache.maven.jrcs.diff;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import java.util.List;
public class ChangeDelta extends Delta {
ChangeDelta() {
super();
}
public ChangeDelta(Chunk orig, Chunk rev) {
init(orig, rev);
}
public void verify(List target) throws PatchFailedException {
if (!original.verify(target))
throw new PatchFailedException();
if (original.first() > target.size())
throw new PatchFailedException("original.first() > target.size()");
}
public void applyTo(List target) {
original.applyDelete(target);
revised.applyAdd(original.first(), target);
}
public void toString(StringBuffer s) {
original.range().toString(s);
s.append("c");
revised.range().toString(s);
s.append(Diff.NL);
original.toString(s, "< ", "\n");
s.append("---");
s.append(Diff.NL);
revised.toString(s, "> ", "\n");
}
public void toRCSString(StringBuffer s, String EOL) {
s.append("d");
s.append(original.extfrom());
s.append(" ");
s.append(original.range().length());
s.append(EOL);
s.append("a");
s.append(original.extfrom());
s.append(" ");
s.append(revised.range().length());
s.append(EOL);
revised.toString(s, "", EOL);
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/Chunk.java
Index: Chunk.java
===================================================================
package org.apache.maven.jrcs.diff;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import java.util.*;
/**
* Produces the "Chunk" differences between two sequences
*
* @version $Revision: 1.1 $
* @author Juancarlo A�ez
* @see org.apache.maven.jrcs.diff.Diff
*/
public class Chunk
extends org.apache.maven.jrcs.util.ToString
{
protected int _anchor;
protected int _count;
protected List _chunk;
public Chunk(int pos, int count) {
this._anchor = pos;
this._count = (count >= 0 ? count : 0);
}
public Chunk(Object[] iseq, int pos, int count) {
this(pos, count);
_chunk = slice(iseq, pos, count);
}
public Chunk(Object[] iseq, int pos, int count, int offset) {
this(offset, count);
_chunk = slice(iseq, pos, count);
}
public Chunk(List iseq, int pos, int count) {
this(pos, count);
_chunk = slice(iseq, pos, count);
}
public Chunk(List iseq, int pos, int count, int offset) {
this(offset, count);
_chunk = slice(iseq, pos, count);
}
public int anchor() {
return _anchor;
}
public int size() {
return _count;
}
public int first() {
return anchor();
}
public int last() {
return anchor() + size() - 1;
}
public int extfrom() {
return _anchor + 1;
}
public int extto() {
return _anchor + _count;
}
public Range range() {
return new Range(first(), last());
}
public List chunk() {
return _chunk;
}
public boolean verify(List target) {
if (_chunk == null)
return true;
if (last() > target.size())
return false;
for(int i = 0; i < _count; i++) {
if (!target.get(_anchor+i).equals(_chunk.get(i)))
return false;
}
return true;
}
public void applyDelete(List target) {
for(int i = last(); i >= first(); i--)
target.remove(i);
}
public void applyAdd(int start, List target) {
Iterator i = _chunk.iterator();
while (i.hasNext())
target.add(start++, i.next());
}
public void toString(StringBuffer s) {
toString(s, "", "");
}
public StringBuffer toString(StringBuffer s, String prefix, String postfix) {
if (_chunk != null) {
Iterator i = _chunk.iterator();
while(i.hasNext()) {
s.append(prefix);
s.append(i.next());
s.append(postfix);
}
}
return s;
}
public static List slice(List seq, int pos, int count) {
if (count <= 0)
return new ArrayList(seq.subList(pos,pos));
else
return new ArrayList(seq.subList(pos, pos+count));
}
public static List slice(Object[] seq, int pos, int count) {
return slice(Arrays.asList(seq), pos, count);
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/DeleteDelta.java
Index: DeleteDelta.java
===================================================================
package org.apache.maven.jrcs.diff;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import java.util.List;
public class DeleteDelta extends Delta {
DeleteDelta() {
super();
}
public DeleteDelta(Chunk orig) {
init(orig, null);
}
public void verify(List target) throws PatchFailedException {
if (!original.verify(target))
throw new PatchFailedException();
}
public void applyTo(List target) {
original.applyDelete(target);
}
public void toString(StringBuffer s) {
s.append(original.range());
s.append("d");
s.append(revised.extto());
s.append(Diff.NL);
original.toString(s, "< ", Diff.NL);
}
public void toRCSString(StringBuffer s, String EOL) {
s.append("d");
s.append(original.extfrom());
s.append(" ");
s.append(original.range().length());
s.append(EOL);
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/Delta.java
Index: Delta.java
===================================================================
package org.apache.maven.jrcs.diff;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import java.util.*;
/**
* Produces the "delta" differences between two sequences
*
* @version 0.1 96/11/07
* @author Juancarlo A�ez
* @see org.apache.maven.jrcs.diff.Diff
*/
public abstract class Delta
extends org.apache.maven.jrcs.util.ToString
{
protected Chunk original;
protected Chunk revised;
static Class[][] DeltaClass;
static {
DeltaClass = new Class[2][2];
try {
DeltaClass[0][0] = org.apache.maven.jrcs.diff.ChangeDelta.class;
DeltaClass[0][1] = org.apache.maven.jrcs.diff.AddDelta.class;
DeltaClass[1][0] = org.apache.maven.jrcs.diff.DeleteDelta.class;
DeltaClass[1][1] = org.apache.maven.jrcs.diff.ChangeDelta.class;
}
catch(Throwable o) {
}
}
public static Delta newDelta(Chunk orig, Chunk rev) {
Class c = DeltaClass[ orig.size() > 0 ? 1 : 0]
[ rev.size() > 0 ? 1 : 0];
Delta result;
try {
result = (Delta) c.newInstance();
} catch(Throwable e) {
System.err.println(e);
return null;
}
result.init(orig, rev);
return result;
}
protected Delta() {
}
protected Delta(Chunk orig, Chunk rev) {
init(orig, rev);
}
protected void init(Chunk orig, Chunk rev) {
original = orig;
revised = rev;
}
public abstract void verify(List target) throws PatchFailedException;
public final void patch(List target) throws PatchFailedException {
verify(target);
try {
applyTo(target);
}
catch(Exception e) {
throw new PatchFailedException(e.getMessage());
}
}
public abstract void applyTo(List target);
public void toString(StringBuffer s) {
original.range().toString(s);
s.append("x");
revised.range().toString(s);
s.append(Diff.NL);
original.toString(s, "> ", "\n");
s.append("---");
s.append(Diff.NL);
revised.toString(s, "< ", "\n");
}
public abstract void toRCSString(StringBuffer s, String EOL);
public String toRCSString(String EOL) {
StringBuffer s = new StringBuffer();
toRCSString(s, EOL);
return s.toString();
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/Diff.java
Index: Diff.java
===================================================================
package org.apache.maven.jrcs.diff;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Set;
import java.util.HashSet;
import java.util.Map;
import java.util.HashMap;
import java.io.BufferedReader;
import java.io.StringReader;
import java.util.Random;
/**
* Produces the "delta" differences between two sequences
*
* @version $Revision: 1.1 $ $Date: 2002/02/20 16:20:02 $
* @author Juancarlo A�ez
* @see org.apache.maven.jrcs.diff.Delta
*/
public class Diff {
public static final String NL = "\n";
static final int NOT_FOUND_i = -2;
static final int NOT_FOUND_j = -1;
static final int EOS = Integer.MAX_VALUE;
Object[] orig;
public Diff(Object[] o) {
if (o == null)
throw new IllegalArgumentException();
orig = o;
}
public static Revision diff(Object[] orig, Object[] rev)
throws DifferentiationFailedException
{
if (orig == null || rev == null)
throw new IllegalArgumentException();
return new Diff(orig).diff(rev);
}
public static boolean compare(Object[] orig, Object[] rev) {
if (orig.length != rev.length)
return false;
else {
for(int i = 0; i < orig.length; i++)
if (! orig[i].equals(rev[i]))
return false;
return true;
}
}
protected int scan(int[] ndx, int i, int target) {
while(ndx[i] < target)
i++;
return i;
}
public Revision diff(Object[] rev) throws DifferentiationFailedException {
Map eqs = buildEqSet(orig, rev);
int[] indx = buildIndex(eqs, orig, NOT_FOUND_i);
int[] jndx = buildIndex(eqs, rev, NOT_FOUND_j);
eqs = null; // let gc know we're done with this
Revision deltas = new Revision(); //!!! new Revision()
int i = 0;
int j = 0;
// skip matching
for(;indx[i] != EOS && indx[i] == jndx[j]; i++, j++)
{/* void */}
while (indx[i] != jndx[j]) { // only equal if both == EOS
// they are different
int ia = i;
int ja = j;
// size of this delta
do {
while(jndx[j] < 0 || jndx[j] < indx[i]) j++;
while(indx[i] < 0 || indx[i] < jndx[j]) i++;
} while(indx[i] != jndx[j]);
// they are equal, reverse any exedent matches
while(i > ia && j > ja && indx[i-1] == jndx[j-1]) {
--i; --j;
//System.err.println("************* reversing "+ i);
}
deltas.addDelta( Delta.newDelta( new Chunk(orig, ia, i-ia),
new Chunk(rev, ja, j-ja)));
// skip matching
for(;indx[i] != EOS && indx[i] == jndx[j]; i++, j++)
{/* void */}
}
try {
if (!compare(deltas.patch(orig), rev))
throw new DifferentiationFailedException();
}
catch(DiffException e) {
throw new DifferentiationFailedException(e.getMessage());
}
return deltas;
}
protected Map buildEqSet(Object[] orig, Object[] rev) {
Set items = new HashSet(Arrays.asList(orig));
items.retainAll(Arrays.asList(rev));
Map eqs = new HashMap();
for(int i = 0; i < orig.length; i++) {
if (items.contains(orig[i])) {
eqs.put(orig[i], new Integer(i));
items.remove(orig[i]);
}
}
return eqs;
}
protected int[] buildIndex(Map eqs, Object[] seq, int NF) {
int[] result = new int[seq.length+1];
for(int i = 0; i < seq.length; i++) {
Integer value = (Integer) eqs.get(seq[i]);
if (value == null || value.intValue() < 0)
result[i] = NF;
else
result[i] = value.intValue();
}
result[seq.length] = EOS;
return result;
}
public static Object[] stringToArray(String value) {
BufferedReader reader = new BufferedReader(new StringReader(value));
List l = new LinkedList();
String s;
try {
while ((s = reader.readLine()) != null)
l.add(s);
}
catch(java.io.IOException e)
{}
return l.toArray();
}
public static String arrayToString(Object[] o) {
return arrayToString(o, Diff.NL);
}
public static String arrayToString(Object[] o, String EOL) {
StringBuffer buf = new StringBuffer();
for (int i = 0; i < o.length-1; i++) {
buf.append(o[i]);
buf.append(EOL);
}
buf.append(o[o.length-1]);
return buf.toString();
}
public static Object[] randomEdit(Object [] text) {
return randomEdit(text, text.length);
}
public static Object[] randomEdit(Object [] text, long seed) {
List result = new ArrayList(Arrays.asList(text));
Random r = new Random(seed);
int nops = r.nextInt(10);
for (int i = 0; i < nops; i++) {
boolean del = r.nextBoolean();
int pos = r.nextInt(result.size()+1);
int len = Math.min(result.size() - pos, 1+r.nextInt(4));
if (del && result.size() > 0) // delete
result.subList(pos, pos + len).clear();
else
for (int k = 0; k < len; k++, pos++)
result.add(pos, "["+i+"] random edit[" + i + "][" + i + "]");
}
return result.toArray();
}
public static Object[] shuffle(Object [] text) {
return randomEdit(text, text.length);
}
public static Object[] shuffle(Object [] text, long seed) {
List result = new ArrayList(Arrays.asList(text));
Random r = new Random(seed);
int nops = r.nextInt(10);
for (int i = 0; i < nops; i++) {
int p1 = r.nextInt(result.size());
int p2 = r.nextInt(result.size());
Object tmp = result.get(p1);
result.set(p1, result.get(p2));
result.set(p2, tmp);
}
return result.toArray();
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/DiffException.java
Index: DiffException.java
===================================================================
package org.apache.maven.jrcs.diff;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
public class DiffException extends Exception {
public DiffException() {
}
public DiffException(String msg) {
super(msg);
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/DifferentiationFailedException.java
Index: DifferentiationFailedException.java
===================================================================
package org.apache.maven.jrcs.diff;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
public class DifferentiationFailedException extends DiffException {
public DifferentiationFailedException() {
}
public DifferentiationFailedException(String msg) {
super(msg);
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/PatchFailedException.java
Index: PatchFailedException.java
===================================================================
package org.apache.maven.jrcs.diff;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
public class PatchFailedException extends DiffException
{
public PatchFailedException() {
}
public PatchFailedException(String msg) {
super(msg);
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/Range.java
Index: Range.java
===================================================================
package org.apache.maven.jrcs.diff;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/**
* Produces the "Range" differences between two sequences
*
* @version 0.1 96/11/07
* @author Juancarlo A�ez
* @see org.apache.maven.jrcs.diff.Diff
*/
public class Range
extends org.apache.maven.jrcs.util.ToString
{
int _from;
int _to;
public Range(int from, int to) {
_from = from;
_to = to;
}
public int from() {
return _from;
}
public int to() {
return _to;
}
public int length() {
return 1+_to-_from;
}
public void toString(StringBuffer s, String separ) {
if (_from == _to)
s.append(Integer.toString(1+_from));
else {
s.append(Integer.toString(1+_from));
s.append(separ);
s.append(Integer.toString(1+_to));
}
}
public void toString(StringBuffer s) {
toString(s, ",");
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/diff/Revision.java
Index: Revision.java
===================================================================
package org.apache.maven.jrcs.diff;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import java.util.*;
public class Revision
extends org.apache.maven.jrcs.util.ToString
{
List deltas_ = new LinkedList();
public Revision() {
}
public synchronized void addDelta(Delta delta) {
if (delta == null)
throw new IllegalArgumentException("new delta is null");
if (deltas_.size() > 0) {
Delta prev = (Delta) deltas_.get(deltas_.size()-1);
/*!!!
if (prev.original != null && delta.original != null
&& (prev.original.from() > delta.original.from()))
throw new IllegalArgumentException("original.from > new.from");
if (prev.revised != null && delta.revised != null
&& (prev.revised.from() > delta.revised.from()))
throw new IllegalArgumentException("revised.from > revised.to");
*/
}
deltas_.add(delta);
}
public Delta getDelta(int i) {
return (Delta) deltas_.get(i);
}
public int size() {
return deltas_.size();
}
public Object[] patch(Object[] src) throws PatchFailedException {
List target = new ArrayList(Arrays.asList(src));
applyTo(target);
return target.toArray();
}
public synchronized void applyTo(List target) throws PatchFailedException {
ListIterator i = deltas_.listIterator(deltas_.size());
while (i.hasPrevious()) {
Delta delta = (Delta) i.previous();
delta.patch(target);
}
}
public synchronized void toString(StringBuffer s){
Iterator i = deltas_.iterator();
while (i.hasNext())
((Delta)i.next()).toString(s);
}
public synchronized void toRCSString(StringBuffer s, String EOL){
Iterator i = deltas_.iterator();
while (i.hasNext())
((Delta) i.next()).toRCSString(s, EOL);
}
public void toRCSString(StringBuffer s){
toRCSString(s, Diff.NL);
}
public String toRCSString(String EOL) {
StringBuffer s = new StringBuffer();
toRCSString(s, EOL);
return s.toString();
}
public String toRCSString() {
return toRCSString(Diff.NL);
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/ASCII_UCodeESC_CharStream.java
Index: ASCII_UCodeESC_CharStream.java
===================================================================
package org.apache.maven.jrcs.rcs;
/**
* An implementation of interface CharStream, where the stream is assumed to
* contain only ASCII characters (with java-like unicode escape processing).
*/
public final class ASCII_UCodeESC_CharStream
{
public static final boolean staticFlag = false;
static final int hexval(char c) throws java.io.IOException {
switch(c)
{
case '0' :
return 0;
case '1' :
return 1;
case '2' :
return 2;
case '3' :
return 3;
case '4' :
return 4;
case '5' :
return 5;
case '6' :
return 6;
case '7' :
return 7;
case '8' :
return 8;
case '9' :
return 9;
case 'a' :
case 'A' :
return 10;
case 'b' :
case 'B' :
return 11;
case 'c' :
case 'C' :
return 12;
case 'd' :
case 'D' :
return 13;
case 'e' :
case 'E' :
return 14;
case 'f' :
case 'F' :
return 15;
}
throw new java.io.IOException(); // Should never come here
}
public int bufpos = -1;
int bufsize;
int available;
int tokenBegin;
private int bufline[];
private int bufcolumn[];
private int column = 0;
private int line = 1;
private java.io.Reader inputStream;
private boolean prevCharIsCR = false;
private boolean prevCharIsLF = false;
private char[] nextCharBuf;
private char[] buffer;
private int maxNextCharInd = 0;
private int nextCharInd = -1;
private int inBuf = 0;
private final void ExpandBuff(boolean wrapAround)
{
char[] newbuffer = new char[bufsize + 2048];
int newbufline[] = new int[bufsize + 2048];
int newbufcolumn[] = new int[bufsize + 2048];
try
{
if (wrapAround)
{
System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
System.arraycopy(buffer, 0, newbuffer,
bufsize - tokenBegin, bufpos);
buffer = newbuffer;
System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
bufline = newbufline;
System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
bufcolumn = newbufcolumn;
bufpos += (bufsize - tokenBegin);
}
else
{
System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
buffer = newbuffer;
System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
bufline = newbufline;
System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
bufcolumn = newbufcolumn;
bufpos -= tokenBegin;
}
}
catch (Throwable t)
{
throw new Error(t.getMessage());
}
available = (bufsize += 2048);
tokenBegin = 0;
}
private final void FillBuff() throws java.io.IOException
{
int i;
if (maxNextCharInd == 4096)
maxNextCharInd = nextCharInd = 0;
try {
if ((i = inputStream.read(nextCharBuf, maxNextCharInd,
4096 - maxNextCharInd)) == -1)
{
inputStream.close();
throw new java.io.IOException();
}
else
maxNextCharInd += i;
return;
}
catch(java.io.IOException e) {
if (bufpos != 0)
{
--bufpos;
backup(0);
}
else
{
bufline[bufpos] = line;
bufcolumn[bufpos] = column;
}
throw e;
}
}
private final char ReadByte() throws java.io.IOException
{
if (++nextCharInd >= maxNextCharInd)
FillBuff();
return nextCharBuf[nextCharInd];
}
public final char BeginToken() throws java.io.IOException
{
if (inBuf > 0)
{
--inBuf;
return buffer[tokenBegin = (bufpos == bufsize - 1) ? (bufpos = 0)
: ++bufpos];
}
tokenBegin = 0;
bufpos = -1;
return readChar();
}
private final void AdjustBuffSize()
{
if (available == bufsize)
{
if (tokenBegin > 2048)
{
bufpos = 0;
available = tokenBegin;
}
else
ExpandBuff(false);
}
else if (available > tokenBegin)
available = bufsize;
else if ((tokenBegin - available) < 2048)
ExpandBuff(true);
else
available = tokenBegin;
}
private final void UpdateLineColumn(char c)
{
column++;
if (prevCharIsLF)
{
prevCharIsLF = false;
line += (column = 1);
}
else if (prevCharIsCR)
{
prevCharIsCR = false;
if (c == '\n')
{
prevCharIsLF = true;
}
else
line += (column = 1);
}
switch (c)
{
case '\r' :
prevCharIsCR = true;
break;
case '\n' :
prevCharIsLF = true;
break;
case '\t' :
column--;
column += (8 - (column & 07));
break;
default :
break;
}
bufline[bufpos] = line;
bufcolumn[bufpos] = column;
}
public final char readChar() throws java.io.IOException
{
if (inBuf > 0)
{
--inBuf;
return buffer[(bufpos == bufsize - 1) ? (bufpos = 0) : ++bufpos];
}
char c;
if (++bufpos == available)
AdjustBuffSize();
if (((buffer[bufpos] = c = (char)((char)0xff & ReadByte())) == '\\'))
{
UpdateLineColumn(c);
int backSlashCnt = 1;
for (;;) // Read all the backslashes
{
if (++bufpos == available)
AdjustBuffSize();
try
{
if ((buffer[bufpos] = c = (char)((char)0xff & ReadByte())) != '\\')
{
UpdateLineColumn(c);
// found a non-backslash char.
if ((c == 'u') && ((backSlashCnt & 1) == 1))
{
if (--bufpos < 0)
bufpos = bufsize - 1;
break;
}
backup(backSlashCnt);
return '\\';
}
}
catch(java.io.IOException e)
{
if (backSlashCnt > 1)
backup(backSlashCnt);
return '\\';
}
UpdateLineColumn(c);
backSlashCnt++;
}
// Here, we have seen an odd number of backslash's followed by a 'u'
try
{
while ((c = (char)((char)0xff & ReadByte())) == 'u')
++column;
buffer[bufpos] = c = (char)(hexval(c) << 12 |
hexval((char)((char)0xff & ReadByte())) << 8 |
hexval((char)((char)0xff & ReadByte())) << 4 |
hexval((char)((char)0xff & ReadByte())));
column += 4;
}
catch(java.io.IOException e)
{
throw new Error("Invalid escape character at line " + line +
" column " + column + ".");
}
if (backSlashCnt == 1)
return c;
else
{
backup(backSlashCnt - 1);
return '\\';
}
}
else
{
UpdateLineColumn(c);
return (c);
}
}
/**
* @deprecated
* @see #getEndColumn
*/
public final int getColumn() {
return bufcolumn[bufpos];
}
/**
* @deprecated
* @see #getEndLine
*/
public final int getLine() {
return bufline[bufpos];
}
public final int getEndColumn() {
return bufcolumn[bufpos];
}
public final int getEndLine() {
return bufline[bufpos];
}
public final int getBeginColumn() {
return bufcolumn[tokenBegin];
}
public final int getBeginLine() {
return bufline[tokenBegin];
}
public final void backup(int amount) {
inBuf += amount;
if ((bufpos -= amount) < 0)
bufpos += bufsize;
}
public ASCII_UCodeESC_CharStream(java.io.Reader dstream,
int startline, int startcolumn, int buffersize)
{
inputStream = dstream;
line = startline;
column = startcolumn - 1;
available = bufsize = buffersize;
buffer = new char[buffersize];
bufline = new int[buffersize];
bufcolumn = new int[buffersize];
nextCharBuf = new char[4096];
}
public ASCII_UCodeESC_CharStream(java.io.Reader dstream,
int startline, int startcolumn)
{
this(dstream, startline, startcolumn, 4096);
}
public void ReInit(java.io.Reader dstream,
int startline, int startcolumn, int buffersize)
{
inputStream = dstream;
line = startline;
column = startcolumn - 1;
if (buffer == null || buffersize != buffer.length)
{
available = bufsize = buffersize;
buffer = new char[buffersize];
bufline = new int[buffersize];
bufcolumn = new int[buffersize];
nextCharBuf = new char[4096];
}
prevCharIsLF = prevCharIsCR = false;
tokenBegin = inBuf = maxNextCharInd = 0;
nextCharInd = bufpos = -1;
}
public void ReInit(java.io.Reader dstream,
int startline, int startcolumn)
{
ReInit(dstream, startline, startcolumn, 4096);
}
public ASCII_UCodeESC_CharStream(java.io.InputStream dstream, int startline,
int startcolumn, int buffersize)
{
this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
}
public ASCII_UCodeESC_CharStream(java.io.InputStream dstream, int startline,
int startcolumn)
{
this(dstream, startline, startcolumn, 4096);
}
public void ReInit(java.io.InputStream dstream, int startline,
int startcolumn, int buffersize)
{
ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
}
public void ReInit(java.io.InputStream dstream, int startline,
int startcolumn)
{
ReInit(dstream, startline, startcolumn, 4096);
}
public final String GetImage()
{
if (bufpos >= tokenBegin)
return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
else
return new String(buffer, tokenBegin, bufsize - tokenBegin) +
new String(buffer, 0, bufpos + 1);
}
public final char[] GetSuffix(int len)
{
char[] ret = new char[len];
if ((bufpos + 1) >= len)
System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
else
{
System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
len - bufpos - 1);
System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
}
return ret;
}
public void Done()
{
nextCharBuf = null;
buffer = null;
bufline = null;
bufcolumn = null;
}
/**
* Method to adjust line and column numbers for the start of a token.<BR>
*/
public void adjustBeginLineColumn(int newLine, int newCol)
{
int start = tokenBegin;
int len;
if (bufpos >= tokenBegin)
{
len = bufpos - tokenBegin + inBuf + 1;
}
else
{
len = bufsize - tokenBegin + bufpos + 1 + inBuf;
}
int i = 0, j = 0, k = 0;
int nextColDiff = 0, columnDiff = 0;
while (i < len &&
bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
{
bufline[j] = newLine;
nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
bufcolumn[j] = newCol + columnDiff;
columnDiff = nextColDiff;
i++;
}
if (i < len)
{
bufline[j] = newLine++;
bufcolumn[j] = newCol + columnDiff;
while (i++ < len)
{
if (bufline[j = start % bufsize] != bufline[++start % bufsize])
bufline[j] = newLine++;
else
bufline[j] = newLine;
}
}
line = bufline[j];
column = bufcolumn[j];
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/Archive.java
Index: Archive.java
===================================================================
package org.apache.maven.jrcs.rcs;
import org.apache.maven.jrcs.diff.Diff;
import gnu.regexp.*;
import java.util.*;
import java.text.Format;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.text.MessageFormat;
public class Archive
extends org.apache.maven.jrcs.util.ToString
{
public static final String RCS_NEWLINE = "\0x0A";
protected TrunkNode _head;
protected Version _branch;
protected Map _nodes = new TreeMap(); //!!! check Node.compareTo for correct RCS order
protected Set _users = new TreeSet();
protected Set _locked = new TreeSet();
protected Map _symbols = new TreeMap();
protected Phrases _phrases = new Phrases();
protected String _desc = new String();
protected boolean _strictLocking = true;
protected String _expand;
protected String _comment = "# ";
protected String _filename = "?,v";
/**
* Creates a new archive and sets the text of the initial revision.
* @param text The text of the initial revision.
* @param desc The archives description (not the log message).
*/
public Archive(Object[] text, String desc) {
this(text, desc, new Version(1,1));
}
/**
* Creates a new archive with the specified initial version number
* and sets the text of the initial revision.
* The initila revision must be of the form "n.m" (i.e. a trunk revision).
* @param text The text of the initial revision.
* @param desc The archives description (not the log message).
* @param vernum The initial revision number.
*/
public Archive(Object[] text, String desc, String vernum) {
this(text, desc, new Version(vernum));
}
/**
* Creates a new archive with the specified initial version number
* and sets the text of the initial revision.
* The initila revision must be of the form "n.m" (i.e. a trunk revision).
* @param text The text of the initial revision.
* @param desc The archives description (not the log message).
* @param vernum The initial revision number.
*/
protected Archive(Object[] text, String desc, Version vernum) {
// can only add a trunk version
if (vernum.size() > 2)
throw new InvalidVersionNumberException(vernum + " must be a trunk version");
while (vernum.size() < 2)
vernum = vernum.newBranch(1);
// now add the _head node
this._head = (TrunkNode) newNode(vernum, null);
this._head.setText(text);
this._head.setLog("Initial revision\n");
this.setDesc(desc);
}
/**
* Load an archive from an input stream.
* Parses the archive given by the input stream, and gives it the provided name.
* @param fname The name to give to the archive.
* @param input Where to read the archive from
*/
public Archive(String fname, java.io.InputStream input) throws ParseException {
this._filename = fname;
ArchiveParser.load(this, input);
}
/**
* Load an archive from an a file given by name.
* @param path The path to the file wher the archive resides.
*/
public Archive(String path) throws ParseException, java.io.FileNotFoundException {
this._filename = new java.io.File(path).getPath();
ArchiveParser.load(this, this._filename);
}
/**
* Create an unitialized Archive.
* Used internally by the ArchiveParser.
* @see ArchiveParser
*/
Archive() {
}
public void save(java.io.OutputStream output)
throws java.io.IOException
{
new java.io.OutputStreamWriter(output).write(
toString(Archive.RCS_NEWLINE).toCharArray()
);
}
public void save(String path)
throws java.io.IOException
{
save(new java.io.FileOutputStream(path));
this._filename = new java.io.File(path).getPath();
}
protected void setHead(Version vernum) throws InvalidVersionNumberException {
if (_head != null)
throw new HeadAlreadySetException(_head.version);
_head = new TrunkNode(vernum, null);
_nodes.put(vernum, _head);
}
public void setBranch(String v) throws InvalidBranchVersionNumberException {
setBranch(new Version(v));
}
public void setBranch(Version vernum) throws InvalidBranchVersionNumberException {
if (!vernum.isBranch())
throw new InvalidBranchVersionNumberException(vernum);
if (_head == null || vernum.getBase(2).isGreaterThan(_head.version))
throw new InvalidBranchVersionNumberException(vernum + "is greater than _head version " + _head.version);
_branch = vernum;
}
public void addUser(String name) {
_users.add(name);
}
public void addSymbol(String sym, Version vernum) throws InvalidVersionNumberException {
_symbols.put(sym, vernum);
}
public void addLock(String user, Version vernum)
throws InvalidVersionNumberException,
NodeNotFoundException
{
addUser(user);
Node node = newNode(vernum);
node.setLocker(user);
if (user == null)
_locked.remove(node);
else
_locked.add(node);
}
public void setStrictLocking(boolean value) {
_strictLocking = value;
}
public void setExpand(String value) {
_expand = value;
}
public void setComment(String value) {
_comment = value;
}
public void setDesc(String value) {
_desc = value;
}
public void addPhrase(String key, Collection values) {
_phrases.put(key, values);
}
protected Node getNode(Version vernum)
throws InvalidVersionNumberException,
NodeNotFoundException
{
if (!vernum.even())
throw new InvalidVersionNumberException(vernum);
Node node = (Node) _nodes.get(vernum);
if (node == null)
throw new NodeNotFoundException();
else
return node;
}
protected Node newNode(Version vernum) {
return newNode(vernum, null);
}
protected Node newNode(Version vernum, Node prev)
throws InvalidVersionNumberException,
NodeNotFoundException
{
if (!vernum.isRevision())
throw new InvalidVersionNumberException(vernum);
Node node = (Node) _nodes.get(vernum);
if (node == null) {
node = Node.newNode(vernum, prev);
_nodes.put(vernum, node);
}
return node;
}
protected TrunkNode newTrunkNode(Version vernum)
throws InvalidVersionNumberException,
NodeNotFoundException
{
if (!vernum.isTrunk())
throw new InvalidTrunkVersionNumberException(vernum);
return (TrunkNode) newNode(vernum);
}
protected BranchNode newBranchNode(Version vernum)
throws InvalidVersionNumberException,
NodeNotFoundException
{
if (!vernum.isBranch())
throw new InvalidBranchVersionNumberException(vernum);
return (BranchNode) newNode(vernum);
}
protected Node findNode(Version vernum)
throws InvalidVersionNumberException,
NodeNotFoundException
{
if (!vernum.isRevision())
throw new InvalidVersionNumberException(vernum);
Node node = (Node) _nodes.get(vernum);
if (node == null)
throw new NodeNotFoundException(vernum);
return node;
}
public void toString(StringBuffer s) {
toString(s, "\n");
}
public String toString(String EOL) {
StringBuffer s = new StringBuffer();
toString(s, EOL);
return s.toString();
}
protected Path getRevisionPath(Version vernum)
{
if (_head == null)
return null;
try {
Path path = _head.pathTo(vernum, true);
Node revisionFound = path.last();
if (revisionFound == null)
return null;
if (revisionFound.version.isLessThan(vernum))
return null;
return path;
}
catch(NodeNotFoundException e) {
return null;
}
}
public Version getRevisionVersion(Version vernum)
{
Path path = getRevisionPath(vernum);
return (path == null ? null : path.last().version);
}
public Version getRevisionVersion(String v)
{
return getRevisionVersion(new Version(v));
}
public Version getRevisionVersion()
{
if (_branch != null)
return getRevisionVersion(_branch);
else if (_head != null)
return _head.version;
else
return null;
}
public void toString(StringBuffer s, String EOL) {
String EOI = ";"+EOL;
String NLT = EOL + "\t";
s.append("head");
if (_head != null) {
s.append("\t");
_head.version.toString(s);
}
s.append(EOI);
if (_branch != null) {
s.append("branch\t");
s.append(_branch.toString());
s.append(EOI);
}
s.append("access");
for(Iterator i = _users.iterator(); i.hasNext(); ) {
s.append(EOL);
s.append("\t");
s.append(i.next());
}
s.append(EOI);
s.append("symbols");
for(Iterator i = _symbols.entrySet().iterator(); i.hasNext(); ) {
Map.Entry e = (Map.Entry) i.next();
s.append(NLT);
s.append(e.getKey().toString());
s.append(":");
s.append(e.getValue().toString());
}
s.append(EOI);
s.append("locks");
for(Iterator i = _locked.iterator(); i.hasNext(); ) {
String locker = ((Node) i.next())._locker;
s.append(NLT);
s.append(locker);
}
if (_strictLocking)
s.append("; strict");
s.append(EOI);
if (_comment != null) {
s.append("comment\t");
s.append(Archive.quoteString(_comment));
s.append(EOI);
}
if (_expand != null) {
s.append("expand\t");
s.append(Archive.quoteString(_expand));
s.append(EOI);
}
if (_phrases != null)
_phrases.toString(s, EOL);
s.append(EOL);
for(Iterator i = _nodes.values().iterator(); i.hasNext(); ) {
Node n = (Node) i.next();
if (!n.version.isGhost() && n._text != null)
n.toString(s, EOL);
}
s.append(EOL + EOL);
s.append("desc");
s.append(EOL);
s.append(quoteString(_desc));
s.append(EOL);
Node n = _head;
while (n != null) {
n.toText(s, EOL);
n = n.getNext();
}
}
static public String quoteString(String s) {
//!!! use org.apache.maven.jrcs.RegExp here !!!
StringBuffer result = new StringBuffer(s);
for(int i = 0; i < s.length(); i++) {
if (result.charAt(i) == '@')
result.insert(i++, '@');
}
result.insert(0,'@');
result.append('@');
return new String(result);
}
static public String unquoteString(String s) {
return unquoteString(s, true);
}
static public String unquoteString(String s, boolean removeExtremes) {
//!!! use org.apache.maven.jrcs.RegExp here !!!
//!!! always ignore extremes. Check they are @'s, though.
StringBuffer result = new StringBuffer();
int start = 0;
int end = s.length();
if (removeExtremes) {
start += 1;
end -= 1;
}
for(int i = start; i < end; i++) {
char c = s.charAt(i);
result.append(c);
if (c == '@')
i++;
}
return new String(result);
}
public Object[] getRevision()
throws InvalidFileFormatException,
org.apache.maven.jrcs.diff.DiffException,
NodeNotFoundException
{
return getRevision(false);
}
public Object[] getRevision(boolean annotate)
throws InvalidFileFormatException,
org.apache.maven.jrcs.diff.DiffException,
NodeNotFoundException
{
if (_branch != null)
return getRevision(_branch);
else if (_head != null)
return getRevision(_head.version);
else
throw new IllegalStateException("no head node");
}
public Object[] getRevision(String v)
throws InvalidFileFormatException,
org.apache.maven.jrcs.diff.PatchFailedException,
InvalidVersionNumberException,
NodeNotFoundException
{
return getRevision(v, false);
}
public Object[] getRevision(String v, boolean annotate)
throws InvalidVersionNumberException,
NodeNotFoundException,
InvalidFileFormatException,
org.apache.maven.jrcs.diff.PatchFailedException
{
return getRevision(new Version(v), annotate);
}
public Object[] getRevision(Version vernum)
throws InvalidFileFormatException,
org.apache.maven.jrcs.diff.PatchFailedException,
NodeNotFoundException
{
return getRevision(vernum, false);
}
public Object[] getRevision(Version vernum, boolean annotate)
throws InvalidFileFormatException,
org.apache.maven.jrcs.diff.PatchFailedException,
NodeNotFoundException
{
Path path = getRevisionPath(vernum);
if (path == null)
throw new NodeNotFoundException(vernum);
Lines lines = new Lines();
Node revisionFound = path.last();
path.patch(lines, annotate);
return doKeywords(lines.toArray(), revisionFound);
}
public Version addRevision(Object[] text, String log)
throws InvalidFileFormatException,
org.apache.maven.jrcs.diff.DiffException,
InvalidVersionNumberException,
NodeNotFoundException
{
if (_branch != null)
return addRevision(text, _branch, log);
else
return addRevision(text, _head.version.next(), log);
}
public Version addRevision(Object[] text, String vernum, String log)
throws InvalidFileFormatException,
org.apache.maven.jrcs.diff.DiffException,
InvalidVersionNumberException,
NodeNotFoundException
{
return addRevision(text, new Version(vernum), log);
}
public Version addRevision(Object[] text, Version vernum, String log)
throws InvalidFileFormatException,
org.apache.maven.jrcs.diff.DiffException,
NodeNotFoundException,
InvalidVersionNumberException
{
if (_head == null)
throw new IllegalStateException("no _head node");
Path path = _head.pathTo(vernum, true);
Node target = path.last();
if (vernum.size() < target.version.size())
vernum = target.nextVersion();
else if (!vernum.isGreaterThan(target.version))
throw new InvalidVersionNumberException(vernum + " revision must be higher than " + target.version);
else if (vernum.odd())
if (vernum.last() == 0)
vernum = target.newBranchVersion();
else
vernum = vernum.newBranch(1);
else if (vernum.last() == 0)
vernum = vernum.next();
boolean headAdd = (target == _head && !vernum.isBranch());
text = removeKeywords(text);
String deltaText;
if (headAdd)
deltaText = Diff.diff(text, _head._text).toRCSString();
else {
Object[] oldText = path.patch().toArray();
deltaText = Diff.diff(oldText, text).toRCSString();
}
if (deltaText.length() == 0)
return null; // no changes, no new version
Node newNode = null;
if (headAdd) {
newNode = newNode(vernum, _head);
newNode.setText(text);
_head.setText(deltaText);
_head = (TrunkNode) newNode;
}
else { // adding a branch node
newNode = newNode(vernum);
newNode.setText(deltaText);
if (vernum.size() > target.version.size())
target.addBranch((BranchNode) newNode);
else
target.setRCSNext(newNode);
}
newNode.setLog(log);
return newNode.version;
}
protected static final Format Header_FORMAT =
new MessageFormat("Header: {1} {2} {3, date,yyyy/MM/dd HH:mm:ss} {4} {5} ");
protected static final Format Id_FORMAT =
new MessageFormat("Id: {1} {2} {3, date,yyyy/MM/dd HH:mm:ss} {4} {5} ");
protected static final Format RCSFile_FORMAT =
new MessageFormat("RCSfile: {1} ");
protected static final Format Revision_FORMAT =
new MessageFormat("Revision: {2} ");
protected static final Format Date_FORMAT =
new MessageFormat("Date: {3, date,yyyy/MM/dd HH:mm:ss} ");
protected static final Format Author_FORMAT =
new MessageFormat("Author: {4} ");
protected static final Format State_FORMAT =
new MessageFormat("State: {5} ");
protected static final Format Locker_FORMAT =
new MessageFormat("Locker: {6} ");
protected static final Format Source_FORMAT =
new MessageFormat("Source: {0} ");
protected static RE Id_re;
protected static RE Header_re;
protected static RE Source_re;
protected static RE RCSfile_re;
protected static RE Revision_re;
protected static RE Date_re;
protected static RE Author_re;
protected static RE State_re;
protected static RE Locker_re;
static void makeRegularExpressions() throws org.apache.maven.jrcs.diff.PatchFailedException
{
if (Locker_re != null)
return;
try {
Id_re = new RE("\\$Id(:[^\\$]*)?\\$" );
Header_re = new RE("\\$Header(:[^\\$]*)?\\$" );
Source_re = new RE("\\$Source(:[^\\$]*)?\\$" );
RCSfile_re = new RE("\\$RCSfile(:[^\\$]*)?\\$" );
Revision_re = new RE("\\$Revision(:[^\\$]*)?\\$" );
Date_re = new RE("\\$Date(:[^\\$]*)?\\$" );
Author_re = new RE("\\$Author(:[^\\$]*)?\\$" );
State_re = new RE("\\$State(:[^\\$]*)?\\$" );
Locker_re = new RE("\\$Locker(:[^\\$]*)?\\$" );
}
catch(REException e) {
throw new org.apache.maven.jrcs.diff.PatchFailedException(e.getMessage());
}
}
public Object[] doKeywords(Object[] text, Node rev)
throws org.apache.maven.jrcs.diff.PatchFailedException
{
Object[] revisionInfo = new Object[] {
_filename,
new java.io.File(_filename).getName(),
rev.version.toString(),
rev._date,
rev._author,
rev._state,
rev._locker
};
makeRegularExpressions();
Object[] result = new Object[text.length];
for(int i = 0; i < text.length; i++) {
result[i] = Id_re .substituteAll(text[i], "$"+Id_FORMAT.format(revisionInfo)+"$");
result[i] = Header_re .substituteAll(text[i], "$"+Header_FORMAT.format(revisionInfo)+"$");
result[i] = Source_re .substituteAll(text[i], "$"+Source_FORMAT.format(revisionInfo)+"$");
result[i] = RCSfile_re .substituteAll(text[i], "$"+RCSFile_FORMAT.format(revisionInfo)+"$");
result[i] = Revision_re .substituteAll(text[i], "$"+Revision_FORMAT.format(revisionInfo)+"$");
result[i] = Date_re .substituteAll(text[i], "$"+Date_FORMAT.format(revisionInfo)+"$");
result[i] = Author_re .substituteAll(text[i], "$"+Author_FORMAT.format(revisionInfo)+"$");
result[i] = State_re .substituteAll(text[i], "$"+State_FORMAT.format(revisionInfo)+"$");
result[i] = Locker_re .substituteAll(text[i], "$"+Locker_FORMAT.format(revisionInfo)+"$");
//@TODO: should do something about Name and Log
}
return result;
}
protected static Object[] removeKeywords(Object[] text)
throws org.apache.maven.jrcs.diff.PatchFailedException
{
makeRegularExpressions();
Object[] result = new Object[text.length];
for(int i = 0; i < text.length; i++) {
result[i] = Id_re .substituteAll(text[i], "$"+"Id"+"$");
result[i] = Header_re .substituteAll(text[i], "$"+"Header"+"$");
result[i] = Source_re .substituteAll(text[i], "$"+"Source"+"$");
result[i] = RCSfile_re .substituteAll(text[i], "$"+"RCSFile"+"$");
result[i] = Revision_re .substituteAll(text[i], "$"+"Revision"+"$");
result[i] = Date_re .substituteAll(text[i], "$"+"Date"+"$");
result[i] = Author_re .substituteAll(text[i], "$"+"Author"+"$");
result[i] = State_re .substituteAll(text[i], "$"+"State"+"$");
result[i] = Locker_re .substituteAll(text[i], "$"+"Locker"+"$");
//@TODO: should do something about Name and Log
}
return result;
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/ArchiveParser.java
Index: ArchiveParser.java
===================================================================
package org.apache.maven.jrcs.rcs;
import java.util.*;
class ArchiveParser implements ArchiveParserConstants {
static final String ident = "RCS ArchiveParser Parser $version$:";
public static void main(String args[]) {
ArchiveParser parser;
if (args.length == 0) {
System.out.println(ident + " Reading from standard input . . .");
parser = new ArchiveParser(System.in);
} else if (args.length == 1) {
System.out.println(ident + " Reading from file " + args[0] + " . . .");
try {
parser = new ArchiveParser(new java.io.FileInputStream(args[0]));
} catch (java.io.FileNotFoundException e) {
System.out.println(ident + " File " + args[0] + " not found.");
return;
}
} else {
System.out.println(ident+" Usage is one of:");
System.out.println(" java ArchiveParser < inputfile");
System.out.println("OR");
System.out.println(" java ArchiveParser inputfile");
return;
}
parser.parse();
}
public static void load(Archive arc, java.io.InputStream input) throws ParseException {
ArchiveParser parser = new ArchiveParser(input);
parser.archive(arc);
}
public static void load(Archive arc, String fname) throws java.io.FileNotFoundException, ParseException {
load(arc, new java.io.FileInputStream(fname) );
}
public void parse() {
try {
archive(null);
System.out.println("RCS ArchiveParser Parser version 1.1: RCS ArchiveParser parsed successfully.");
} catch (ParseException e) {
System.out.println("RCS ArchiveParser Parser version 1.1: Encountered errors during parse.");
}
}
/**
* PARSER STARTS HERE
*/
final public void archive(Archive arc) throws ParseException {
admin(arc);
label_1:
while (true) {
switch (jj_nt.kind) {
case NUM:
;
break;
default:
break label_1;
}
delta(arc);
}
desc(arc);
label_2:
while (true) {
switch (jj_nt.kind) {
case NUM:
;
break;
default:
break label_2;
}
text(arc);
}
jj_consume_token(0);
}
final public void admin(Archive arc) throws ParseException {
head(arc);
switch (jj_nt.kind) {
case BRANCH:
branch(arc);
break;
default:
;
}
access(arc);
symbols(arc);
locks(arc);
optionals(arc);
}
final public void optionals(Archive arc) throws ParseException {
label_3:
while (true) {
switch (jj_nt.kind) {
case COMMENT:
case EXPAND:
case ID:
;
break;
default:
break label_3;
}
switch (jj_nt.kind) {
case COMMENT:
comment(arc);
break;
case EXPAND:
expand(arc);
break;
case ID:
newPhrase(arc._phrases);
break;
default:
jj_consume_token(-1);
throw new ParseException();
}
}
}
final public void newPhrases(Map map) throws ParseException {
label_4:
while (true) {
switch (jj_nt.kind) {
case ID:
;
break;
default:
break label_4;
}
newPhrase(map);
}
}
final public void head(Archive arc) throws ParseException {
Version v;
jj_consume_token(HEAD);
switch (jj_nt.kind) {
case NUM:
v = version();
arc.setHead(v);
break;
default:
;
}
jj_consume_token(29);
}
final public void branch(Archive arc) throws ParseException {
Version v;
jj_consume_token(BRANCH);
switch (jj_nt.kind) {
case NUM:
v = version();
arc.setBranch(v);
break;
default:
;
}
jj_consume_token(29);
}
final public void access(Archive arc) throws ParseException {
String name;
jj_consume_token(ACCESS);
label_5:
while (true) {
switch (jj_nt.kind) {
case ID:
;
break;
default:
break label_5;
}
name = id();
arc.addUser(name);
}
jj_consume_token(29);
}
final public void symbols(Archive arc) throws ParseException {
String s;
Version v;
jj_consume_token(SYMBOLS);
label_6:
while (true) {
switch (jj_nt.kind) {
case ID:
case SYM:
;
break;
default:
break label_6;
}
s = sym();
jj_consume_token(30);
v = version();
arc.addSymbol(s, v);
}
jj_consume_token(29);
}
final public void locks(Archive arc) throws ParseException {
String name;
Version v;
jj_consume_token(LOCKS);
label_7:
while (true) {
switch (jj_nt.kind) {
case ID:
;
break;
default:
break label_7;
}
name = id();
jj_consume_token(30);
v = version();
arc.addLock(name, v);
}
jj_consume_token(29);
switch (jj_nt.kind) {
case STRICT:
jj_consume_token(STRICT);
jj_consume_token(29);
arc.setStrictLocking(true);
break;
default:
;
}
}
final public void comment(Archive arc) throws ParseException {
String s;
jj_consume_token(COMMENT);
switch (jj_nt.kind) {
case STRING:
s = string();
arc.setComment(s);
break;
default:
;
}
jj_consume_token(29);
}
final public void expand(Archive arc) throws ParseException {
String s;
jj_consume_token(EXPAND);
switch (jj_nt.kind) {
case STRING:
s = string();
arc.setExpand(s);
break;
default:
;
}
jj_consume_token(29);
}
final public void newPhrase(Map map) throws ParseException {
String key;
String value;
StringBuffer values = new StringBuffer();
key = id();
label_8:
while (true) {
switch (jj_nt.kind) {
case ID:
case STRING:
case NUM:
;
break;
default:
break label_8;
}
value = word();
values.append(" " + value);
}
jj_consume_token(29);
if (map != null) map.put(key, values.toString());
}
final public String word() throws ParseException {
String result;
if (jj_2_1(2)) {
result = pair();
} else {
switch (jj_nt.kind) {
case ID:
case STRING:
case NUM:
result = simpleWord();
break;
default:
jj_consume_token(-1);
throw new ParseException();
}
}
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public String simpleWord() throws ParseException {
String result;
Version v;
switch (jj_nt.kind) {
case ID:
result = id();
break;
case NUM:
v = version();
result = v.toString();
break;
case STRING:
result = string();
break;
default:
jj_consume_token(-1);
throw new ParseException();
}
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public String pair() throws ParseException {
String left;
String right;
left = simpleWord();
jj_consume_token(30);
right = simpleWord();
{if (true) return left + ":" + right;}
throw new Error("Missing return statement in function");
}
final public void desc(Archive arc) throws ParseException {
String s;
jj_consume_token(DESC);
s = string();
arc.setDesc(s);
}
final public void delta(Archive arc) throws ParseException {
Version v;
Node node;
int[] d;
String s;
v = version();
node = arc.newNode(v);
jj_consume_token(DATE);
d = date();
node.setDate(d);
jj_consume_token(29);
jj_consume_token(AUTHOR);
s = id();
node.setAuthor(s);
jj_consume_token(29);
jj_consume_token(STATE);
switch (jj_nt.kind) {
case ID:
s = id();
node.setState(s);
break;
default:
;
}
jj_consume_token(29);
jj_consume_token(BRANCHES);
label_9:
while (true) {
switch (jj_nt.kind) {
case NUM:
;
break;
default:
break label_9;
}
v = version();
node.addBranch(arc.newBranchNode(v));
}
jj_consume_token(29);
jj_consume_token(NEXT);
switch (jj_nt.kind) {
case NUM:
v = version();
node.setRCSNext(arc.newNode(v));
break;
default:
;
}
jj_consume_token(29);
newPhrases(node._phrases);
}
final public void text(Archive arc) throws ParseException {
Version v;
Node node;
String log;
String txt;
v = version();
node = arc.findNode(v);
jj_consume_token(LOG);
log = string();
node.setLog(log);
newPhrases(node._phrases);
jj_consume_token(TEXT);
txt = string();
node.setText(txt);
}
final public String id() throws ParseException {
Token t;
t = jj_consume_token(ID);
{if (true) return t.image;}
throw new Error("Missing return statement in function");
}
final public String sym() throws ParseException {
Token t;
switch (jj_nt.kind) {
case SYM:
t = jj_consume_token(SYM);
break;
case ID:
t = jj_consume_token(ID);
break;
default:
jj_consume_token(-1);
throw new ParseException();
}
{if (true) return t.image;}
throw new Error("Missing return statement in function");
}
final public Version version() throws ParseException {
Version v;
int n, r;
n = num();
v = new Version(n);
label_10:
while (true) {
switch (jj_nt.kind) {
case 31:
;
break;
default:
break label_10;
}
jj_consume_token(31);
n = num();
v.__addBranch(n);
}
{if (true) return v;}
throw new Error("Missing return statement in function");
}
final public int[] date() throws ParseException {
int[] n = new int[6];
n[0] = num();
jj_consume_token(31);
n[1] = num();
jj_consume_token(31);
n[2] = num();
jj_consume_token(31);
n[3] = num();
jj_consume_token(31);
n[4] = num();
jj_consume_token(31);
n[5] = num();
{if (true) return n;}
throw new Error("Missing return statement in function");
}
final public int num() throws ParseException {
Token t;
t = jj_consume_token(NUM);
{if (true) return Integer.parseInt(t.image);}
throw new Error("Missing return statement in function");
}
final public String string() throws ParseException {
Token t;
t = jj_consume_token(STRING);
{if (true) return Archive.unquoteString(t.image);}
throw new Error("Missing return statement in function");
}
final private boolean jj_2_1(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
return !jj_3_1();
}
final private boolean jj_3R_15() {
if (jj_3R_18()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
final private boolean jj_3R_14() {
if (jj_3R_17()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
final private boolean jj_3R_20() {
if (jj_scan_token(31)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
final private boolean jj_3R_13() {
if (jj_3R_16()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
final private boolean jj_3R_12() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_13()) {
jj_scanpos = xsp;
if (jj_3R_14()) {
jj_scanpos = xsp;
if (jj_3R_15()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
} else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
} else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
final private boolean jj_3R_18() {
if (jj_scan_token(STRING)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
final private boolean jj_3R_17() {
if (jj_3R_19()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
Token xsp;
while (true) {
xsp = jj_scanpos;
if (jj_3R_20()) { jj_scanpos = xsp; break; }
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
}
return false;
}
final private boolean jj_3R_11() {
if (jj_3R_12()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
if (jj_scan_token(30)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
final private boolean jj_3R_19() {
if (jj_scan_token(NUM)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
final private boolean jj_3_1() {
if (jj_3R_11()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
final private boolean jj_3R_16() {
if (jj_scan_token(ID)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
public ArchiveParserTokenManager token_source;
ASCII_UCodeESC_CharStream jj_input_stream;
public Token token, jj_nt;
private Token jj_scanpos, jj_lastpos;
private int jj_la;
public boolean lookingAhead = false;
private boolean jj_semLA;
public ArchiveParser(java.io.InputStream stream) {
jj_input_stream = new ASCII_UCodeESC_CharStream(stream, 1, 1);
token_source = new ArchiveParserTokenManager(jj_input_stream);
token = new Token();
token.next = jj_nt = token_source.getNextToken();
}
public void ReInit(java.io.InputStream stream) {
jj_input_stream.ReInit(stream, 1, 1);
token_source.ReInit(jj_input_stream);
token = new Token();
token.next = jj_nt = token_source.getNextToken();
}
public ArchiveParser(java.io.Reader stream) {
jj_input_stream = new ASCII_UCodeESC_CharStream(stream, 1, 1);
token_source = new ArchiveParserTokenManager(jj_input_stream);
token = new Token();
token.next = jj_nt = token_source.getNextToken();
}
public void ReInit(java.io.Reader stream) {
jj_input_stream.ReInit(stream, 1, 1);
token_source.ReInit(jj_input_stream);
token = new Token();
token.next = jj_nt = token_source.getNextToken();
}
public ArchiveParser(ArchiveParserTokenManager tm) {
token_source = tm;
token = new Token();
token.next = jj_nt = token_source.getNextToken();
}
public void ReInit(ArchiveParserTokenManager tm) {
token_source = tm;
token = new Token();
token.next = jj_nt = token_source.getNextToken();
}
final private Token jj_consume_token(int kind) throws ParseException {
Token oldToken = token;
if ((token = jj_nt).next != null) jj_nt = jj_nt.next;
else jj_nt = jj_nt.next = token_source.getNextToken();
if (token.kind == kind) {
return token;
}
jj_nt = token;
token = oldToken;
throw generateParseException();
}
final private boolean jj_scan_token(int kind) {
if (jj_scanpos == jj_lastpos) {
jj_la--;
if (jj_scanpos.next == null) {
jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
} else {
jj_lastpos = jj_scanpos = jj_scanpos.next;
}
} else {
jj_scanpos = jj_scanpos.next;
}
return (jj_scanpos.kind != kind);
}
final public Token getNextToken() {
if ((token = jj_nt).next != null) jj_nt = jj_nt.next;
else jj_nt = jj_nt.next = token_source.getNextToken();
return token;
}
final public Token getToken(int index) {
Token t = lookingAhead ? jj_scanpos : token;
for (int i = 0; i < index; i++) {
if (t.next != null) t = t.next;
else t = t.next = token_source.getNextToken();
}
return t;
}
final public ParseException generateParseException() {
Token errortok = token.next;
int line = errortok.beginLine, column = errortok.beginColumn;
String mess = (errortok.kind == 0) ? tokenImage[0] : errortok.image;
return new ParseException("Parse error at line " + line + ", column " + column + ". Encountered: " + mess);
}
final public void enable_tracing() {
}
final public void disable_tracing() {
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/ArchiveParserConstants.java
Index: ArchiveParserConstants.java
===================================================================
package org.apache.maven.jrcs.rcs;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
public interface ArchiveParserConstants {
int EOF = 0;
int ACCESS = 6;
int AUTHOR = 7;
int BRANCH = 8;
int BRANCHES = 9;
int COMMENT = 10;
int DATE = 11;
int DESC = 12;
int EXPAND = 13;
int HEAD = 14;
int LOCKS = 15;
int LOG = 16;
int NEXT = 17;
int STATE = 18;
int STRICT = 19;
int SYMBOLS = 20;
int TEXT = 21;
int ID = 22;
int SYM = 23;
int IDCHAR = 24;
int STRING = 25;
int LETTER = 26;
int DIGIT = 27;
int NUM = 28;
int DEFAULT = 0;
int PRE_DELTA = 1;
String[] tokenImage = {
"<EOF>",
"\" \"",
"\"\\n\"",
"\"\\t\"",
"\"\\r\"",
"\"\\f\"",
"\"access\"",
"\"author\"",
"\"branch\"",
"\"branches\"",
"\"comment\"",
"\"date\"",
"\"desc\"",
"\"expand\"",
"\"head\"",
"\"locks\"",
"\"log\"",
"\"next\"",
"\"state\"",
"\"strict\"",
"\"symbols\"",
"\"text\"",
"<ID>",
"<SYM>",
"<IDCHAR>",
"<STRING>",
"<LETTER>",
"<DIGIT>",
"<NUM>",
"\";\"",
"\":\"",
"\".\"",
};
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/ArchiveParserTokenManager.java
Index: ArchiveParserTokenManager.java
===================================================================
package org.apache.maven.jrcs.rcs;
import java.util.*;
public class ArchiveParserTokenManager implements ArchiveParserConstants
{
private final int jjStopStringLiteralDfa_0(int pos, long active0)
{
switch (pos)
{
case 0:
if ((active0 & 0x3fffc0L) != 0L)
{
jjmatchedKind = 22;
return 14;
}
return -1;
case 1:
if ((active0 & 0x3fffc0L) != 0L)
{
jjmatchedKind = 22;
jjmatchedPos = 1;
return 14;
}
return -1;
case 2:
if ((active0 & 0x10000L) != 0L)
return 14;
if ((active0 & 0x3effc0L) != 0L)
{
jjmatchedKind = 22;
jjmatchedPos = 2;
return 14;
}
return -1;
case 3:
if ((active0 & 0x225800L) != 0L)
return 14;
if ((active0 & 0x1ca7c0L) != 0L)
{
jjmatchedKind = 22;
jjmatchedPos = 3;
return 14;
}
return -1;
case 4:
if ((active0 & 0x48000L) != 0L)
return 14;
if ((active0 & 0x1827c0L) != 0L)
{
jjmatchedKind = 22;
jjmatchedPos = 4;
return 14;
}
return -1;
case 5:
if ((active0 & 0x823c0L) != 0L)
return 14;
if ((active0 & 0x100400L) != 0L)
{
if (jjmatchedPos != 5)
{
jjmatchedKind = 22;
jjmatchedPos = 5;
}
return 14;
}
return -1;
case 6:
if ((active0 & 0x100400L) != 0L)
return 14;
if ((active0 & 0x200L) != 0L)
{
jjmatchedKind = 22;
jjmatchedPos = 6;
return 14;
}
return -1;
default :
return -1;
}
}
private final int jjStartNfa_0(int pos, long active0)
{
return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);
}
private final int jjStopAtPos(int pos, int kind)
{
jjmatchedKind = kind;
jjmatchedPos = pos;
return pos + 1;
}
private final int jjStartNfaWithStates_0(int pos, int kind, int state)
{
jjmatchedKind = kind;
jjmatchedPos = pos;
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) { return pos + 1; }
return jjMoveNfa_0(state, pos + 1);
}
private final int jjMoveStringLiteralDfa0_0()
{
switch(curChar)
{
case 46:
return jjStopAtPos(0, 31);
case 58:
return jjStopAtPos(0, 30);
case 59:
return jjStopAtPos(0, 29);
case 97:
return jjMoveStringLiteralDfa1_0(0xc0L);
case 98:
return jjMoveStringLiteralDfa1_0(0x300L);
case 99:
return jjMoveStringLiteralDfa1_0(0x400L);
case 100:
return jjMoveStringLiteralDfa1_0(0x1800L);
case 101:
return jjMoveStringLiteralDfa1_0(0x2000L);
case 104:
return jjMoveStringLiteralDfa1_0(0x4000L);
case 108:
return jjMoveStringLiteralDfa1_0(0x18000L);
case 110:
return jjMoveStringLiteralDfa1_0(0x20000L);
case 115:
return jjMoveStringLiteralDfa1_0(0x1c0000L);
case 116:
return jjMoveStringLiteralDfa1_0(0x200000L);
default :
return jjMoveNfa_0(0, 0);
}
}
private final int jjMoveStringLiteralDfa1_0(long active0)
{
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(0, active0);
return 1;
}
switch(curChar)
{
case 97:
return jjMoveStringLiteralDfa2_0(active0, 0x800L);
case 99:
return jjMoveStringLiteralDfa2_0(active0, 0x40L);
case 101:
return jjMoveStringLiteralDfa2_0(active0, 0x225000L);
case 111:
return jjMoveStringLiteralDfa2_0(active0, 0x18400L);
case 114:
return jjMoveStringLiteralDfa2_0(active0, 0x300L);
case 116:
return jjMoveStringLiteralDfa2_0(active0, 0xc0000L);
case 117:
return jjMoveStringLiteralDfa2_0(active0, 0x80L);
case 120:
return jjMoveStringLiteralDfa2_0(active0, 0x2000L);
case 121:
return jjMoveStringLiteralDfa2_0(active0, 0x100000L);
default :
break;
}
return jjStartNfa_0(0, active0);
}
private final int jjMoveStringLiteralDfa2_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
return jjStartNfa_0(0, old0);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(1, active0);
return 2;
}
switch(curChar)
{
case 97:
return jjMoveStringLiteralDfa3_0(active0, 0x44300L);
case 99:
return jjMoveStringLiteralDfa3_0(active0, 0x8040L);
case 103:
if ((active0 & 0x10000L) != 0L)
return jjStartNfaWithStates_0(2, 16, 14);
break;
case 109:
return jjMoveStringLiteralDfa3_0(active0, 0x100400L);
case 112:
return jjMoveStringLiteralDfa3_0(active0, 0x2000L);
case 114:
return jjMoveStringLiteralDfa3_0(active0, 0x80000L);
case 115:
return jjMoveStringLiteralDfa3_0(active0, 0x1000L);
case 116:
return jjMoveStringLiteralDfa3_0(active0, 0x880L);
case 120:
return jjMoveStringLiteralDfa3_0(active0, 0x220000L);
default :
break;
}
return jjStartNfa_0(1, active0);
}
private final int jjMoveStringLiteralDfa3_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
return jjStartNfa_0(1, old0);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(2, active0);
return 3;
}
switch(curChar)
{
case 97:
return jjMoveStringLiteralDfa4_0(active0, 0x2000L);
case 98:
return jjMoveStringLiteralDfa4_0(active0, 0x100000L);
case 99:
if ((active0 & 0x1000L) != 0L)
return jjStartNfaWithStates_0(3, 12, 14);
break;
case 100:
if ((active0 & 0x4000L) != 0L)
return jjStartNfaWithStates_0(3, 14, 14);
break;
case 101:
if ((active0 & 0x800L) != 0L)
return jjStartNfaWithStates_0(3, 11, 14);
return jjMoveStringLiteralDfa4_0(active0, 0x40L);
case 104:
return jjMoveStringLiteralDfa4_0(active0, 0x80L);
case 105:
return jjMoveStringLiteralDfa4_0(active0, 0x80000L);
case 107:
return jjMoveStringLiteralDfa4_0(active0, 0x8000L);
case 109:
return jjMoveStringLiteralDfa4_0(active0, 0x400L);
case 110:
return jjMoveStringLiteralDfa4_0(active0, 0x300L);
case 116:
if ((active0 & 0x20000L) != 0L)
return jjStartNfaWithStates_0(3, 17, 14);
else if ((active0 & 0x200000L) != 0L)
return jjStartNfaWithStates_0(3, 21, 14);
return jjMoveStringLiteralDfa4_0(active0, 0x40000L);
default :
break;
}
return jjStartNfa_0(2, active0);
}
private final int jjMoveStringLiteralDfa4_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
return jjStartNfa_0(2, old0);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(3, active0);
return 4;
}
switch(curChar)
{
case 99:
return jjMoveStringLiteralDfa5_0(active0, 0x80300L);
case 101:
if ((active0 & 0x40000L) != 0L)
return jjStartNfaWithStates_0(4, 18, 14);
return jjMoveStringLiteralDfa5_0(active0, 0x400L);
case 110:
return jjMoveStringLiteralDfa5_0(active0, 0x2000L);
case 111:
return jjMoveStringLiteralDfa5_0(active0, 0x100080L);
case 115:
if ((active0 & 0x8000L) != 0L)
return jjStartNfaWithStates_0(4, 15, 14);
return jjMoveStringLiteralDfa5_0(active0, 0x40L);
default :
break;
}
return jjStartNfa_0(3, active0);
}
private final int jjMoveStringLiteralDfa5_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
return jjStartNfa_0(3, old0);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(4, active0);
return 5;
}
switch(curChar)
{
case 100:
if ((active0 & 0x2000L) != 0L)
return jjStartNfaWithStates_0(5, 13, 14);
break;
case 104:
if ((active0 & 0x100L) != 0L)
{
jjmatchedKind = 8;
jjmatchedPos = 5;
}
return jjMoveStringLiteralDfa6_0(active0, 0x200L);
case 108:
return jjMoveStringLiteralDfa6_0(active0, 0x100000L);
case 110:
return jjMoveStringLiteralDfa6_0(active0, 0x400L);
case 114:
if ((active0 & 0x80L) != 0L)
return jjStartNfaWithStates_0(5, 7, 14);
break;
case 115:
if ((active0 & 0x40L) != 0L)
return jjStartNfaWithStates_0(5, 6, 14);
break;
case 116:
if ((active0 & 0x80000L) != 0L)
return jjStartNfaWithStates_0(5, 19, 14);
break;
default :
break;
}
return jjStartNfa_0(4, active0);
}
private final int jjMoveStringLiteralDfa6_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
return jjStartNfa_0(4, old0);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(5, active0);
return 6;
}
switch(curChar)
{
case 101:
return jjMoveStringLiteralDfa7_0(active0, 0x200L);
case 115:
if ((active0 & 0x100000L) != 0L)
return jjStartNfaWithStates_0(6, 20, 14);
break;
case 116:
if ((active0 & 0x400L) != 0L)
return jjStartNfaWithStates_0(6, 10, 14);
break;
default :
break;
}
return jjStartNfa_0(5, active0);
}
private final int jjMoveStringLiteralDfa7_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
return jjStartNfa_0(5, old0);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(6, active0);
return 7;
}
switch(curChar)
{
case 115:
if ((active0 & 0x200L) != 0L)
return jjStartNfaWithStates_0(7, 9, 14);
break;
default :
break;
}
return jjStartNfa_0(6, active0);
}
private final void jjCheckNAdd(int state)
{
if (jjrounds[state] != jjround)
{
jjstateSet[jjnewStateCnt++] = state;
jjrounds[state] = jjround;
}
}
private final void jjAddStates(int start, int end)
{
do {
jjstateSet[jjnewStateCnt++] = jjnextStates[start];
} while (start++ != end);
}
private final void jjCheckNAddTwoStates(int state1, int state2)
{
jjCheckNAdd(state1);
jjCheckNAdd(state2);
}
private final void jjCheckNAddStates(int start, int end)
{
do {
jjCheckNAdd(jjnextStates[start]);
} while (start++ != end);
}
private final void jjCheckNAddStates(int start)
{
jjCheckNAdd(jjnextStates[start]);
jjCheckNAdd(jjnextStates[start + 1]);
}
static final long[] jjbitVec0 = {
0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
};
static final long[] jjbitVec2 = {
0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
};
static final long[] jjbitVec3 = {
0x1ff00000fffffffeL, 0xffffffffffffc000L, 0xffffffffL, 0x600000000000000L
};
static final long[] jjbitVec4 = {
0x0L, 0x0L, 0x0L, 0xff7fffffff7fffffL
};
static final long[] jjbitVec5 = {
0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
};
static final long[] jjbitVec6 = {
0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffL, 0x0L
};
static final long[] jjbitVec7 = {
0xffffffffffffffffL, 0xffffffffffffffffL, 0x0L, 0x0L
};
static final long[] jjbitVec8 = {
0x3fffffffffffL, 0x0L, 0x0L, 0x0L
};
private final int jjMoveNfa_0(int startState, int curPos)
{
int[] nextStates;
int startsAt = 0;
jjnewStateCnt = 14;
int i = 1;
jjstateSet[0] = startState;
int j, kind = 0x7fffffff;
for (;;)
{
if (++jjround == 0x7fffffff)
ReInitRounds();
if (curChar < 64)
{
long l = 1L << curChar;
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 0:
if ((0x3ff000000000000L & l) != 0L)
{
if (kind > 28)
kind = 28;
jjCheckNAddStates(0, 4);
}
else if (curChar == 36)
{
if (kind > 22)
kind = 22;
jjCheckNAddStates(5, 8);
}
break;
case 14:
if ((0x3ff000000000000L & l) != 0L)
{
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(10, 11);
}
else if (curChar == 36)
{
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(10, 11);
}
if ((0x3ff000000000000L & l) != 0L)
{
if (kind > 22)
kind = 22;
jjCheckNAddTwoStates(7, 8);
}
else if (curChar == 36)
{
if (kind > 22)
kind = 22;
jjCheckNAddTwoStates(7, 8);
}
break;
case 1:
jjAddStates(9, 11);
break;
case 5:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 28)
kind = 28;
jjCheckNAddStates(0, 4);
break;
case 6:
if ((0x3ff000000000000L & l) != 0L)
jjCheckNAddTwoStates(6, 7);
break;
case 7:
if (curChar != 36)
break;
if (kind > 22)
kind = 22;
jjCheckNAddTwoStates(7, 8);
break;
case 8:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 22)
kind = 22;
jjCheckNAddTwoStates(7, 8);
break;
case 9:
if ((0x3ff000000000000L & l) != 0L)
jjCheckNAddTwoStates(9, 10);
break;
case 10:
if (curChar != 36)
break;
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(10, 11);
break;
case 11:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(10, 11);
break;
case 12:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 28)
kind = 28;
jjCheckNAdd(12);
break;
case 13:
if (curChar != 36)
break;
if (kind > 22)
kind = 22;
jjCheckNAddStates(5, 8);
break;
default : break;
}
} while(i != startsAt);
}
else if (curChar < 128)
{
long l = 1L << (curChar & 077);
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 0:
if ((0x7fffffe87fffffeL & l) != 0L)
{
if (kind > 22)
kind = 22;
jjCheckNAddStates(5, 8);
}
else if (curChar == 64)
jjCheckNAddStates(9, 11);
break;
case 14:
if ((0x7fffffe87fffffeL & l) != 0L)
{
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(10, 11);
}
if ((0x7fffffe87fffffeL & l) != 0L)
{
if (kind > 22)
kind = 22;
jjCheckNAddTwoStates(7, 8);
}
break;
case 1:
if ((0xfffffffffffffffeL & l) != 0L)
jjCheckNAddStates(9, 11);
break;
case 2:
if (curChar == 64)
jjCheckNAddStates(9, 11);
break;
case 3:
if (curChar == 64)
jjstateSet[jjnewStateCnt++] = 2;
break;
case 4:
if (curChar == 64 && kind > 25)
kind = 25;
break;
case 7:
if ((0x7fffffe87fffffeL & l) == 0L)
break;
if (kind > 22)
kind = 22;
jjCheckNAddTwoStates(7, 8);
break;
case 10:
if ((0x7fffffe87fffffeL & l) == 0L)
break;
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(10, 11);
break;
case 13:
if ((0x7fffffe87fffffeL & l) == 0L)
break;
if (kind > 22)
kind = 22;
jjCheckNAddStates(5, 8);
break;
default : break;
}
} while(i != startsAt);
}
else
{
int hiByte = (int)(curChar >> 8);
int i1 = hiByte >> 6;
long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
long l2 = 1L << (curChar & 077);
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 0:
if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
break;
if (kind > 22)
kind = 22;
jjCheckNAddStates(5, 8);
break;
case 14:
if (jjCanMove_1(hiByte, i1, i2, l1, l2))
{
if (kind > 22)
kind = 22;
jjCheckNAddTwoStates(7, 8);
}
if (jjCanMove_1(hiByte, i1, i2, l1, l2))
{
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(10, 11);
}
break;
case 1:
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjAddStates(9, 11);
break;
case 7:
if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
break;
if (kind > 22)
kind = 22;
jjCheckNAddTwoStates(7, 8);
break;
case 10:
if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
break;
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(10, 11);
break;
default : break;
}
} while(i != startsAt);
}
if (kind != 0x7fffffff)
{
jjmatchedKind = kind;
jjmatchedPos = curPos;
kind = 0x7fffffff;
}
++curPos;
if ((i = jjnewStateCnt) == (startsAt = 14 - (jjnewStateCnt = startsAt)))
return curPos;
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) { return curPos; }
}
}
private final int jjMoveStringLiteralDfa0_1()
{
switch(curChar)
{
default :
return 1;
}
}
static final int[] jjnextStates = {
6, 7, 9, 10, 12, 7, 8, 10, 11, 1, 3, 4,
};
private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2)
{
switch(hiByte)
{
case 0:
return ((jjbitVec2[i2] & l2) != 0L);
default :
if ((jjbitVec0[i1] & l1) != 0L)
return true;
return false;
}
}
private static final boolean jjCanMove_1(int hiByte, int i1, int i2, long l1, long l2)
{
switch(hiByte)
{
case 0:
return ((jjbitVec4[i2] & l2) != 0L);
case 48:
return ((jjbitVec5[i2] & l2) != 0L);
case 49:
return ((jjbitVec6[i2] & l2) != 0L);
case 51:
return ((jjbitVec7[i2] & l2) != 0L);
case 61:
return ((jjbitVec8[i2] & l2) != 0L);
default :
if ((jjbitVec3[i1] & l1) != 0L)
return true;
return false;
}
}
public static final String[] jjstrLiteralImages = {
"", null, null, null, null, null, "\141\143\143\145\163\163",
"\141\165\164\150\157\162", "\142\162\141\156\143\150", "\142\162\141\156\143\150\145\163",
"\143\157\155\155\145\156\164", "\144\141\164\145", "\144\145\163\143", "\145\170\160\141\156\144",
"\150\145\141\144", "\154\157\143\153\163", "\154\157\147", "\156\145\170\164",
"\163\164\141\164\145", "\163\164\162\151\143\164", "\163\171\155\142\157\154\163",
"\164\145\170\164", null, null, null, null, null, null, null, "\73", "\72", "\56", };
public static final String[] lexStateNames = {
"DEFAULT",
"PRE_DELTA",
};
public static final int[] jjnewLexState = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1,
};
static final long[] jjtoToken = {
0xf3ffffc1L,
};
static final long[] jjtoSkip = {
0x3eL,
};
private ASCII_UCodeESC_CharStream input_stream;
private final int[] jjrounds = new int[14];
private final int[] jjstateSet = new int[28];
protected char curChar;
public ArchiveParserTokenManager(ASCII_UCodeESC_CharStream stream)
{
if (ASCII_UCodeESC_CharStream.staticFlag)
throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
input_stream = stream;
}
public ArchiveParserTokenManager(ASCII_UCodeESC_CharStream stream, int lexState)
{
this(stream);
SwitchTo(lexState);
}
public void ReInit(ASCII_UCodeESC_CharStream stream)
{
jjmatchedPos = jjnewStateCnt = 0;
curLexState = defaultLexState;
input_stream = stream;
ReInitRounds();
}
private final void ReInitRounds()
{
int i;
jjround = 0x80000001;
for (i = 14; i-- > 0;)
jjrounds[i] = 0x80000000;
}
public void ReInit(ASCII_UCodeESC_CharStream stream, int lexState)
{
ReInit(stream);
SwitchTo(lexState);
}
public void SwitchTo(int lexState)
{
if (lexState >= 2 || lexState < 0)
throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
else
curLexState = lexState;
}
private final Token jjFillToken()
{
Token t = Token.newToken(jjmatchedKind);
t.kind = jjmatchedKind;
String im = jjstrLiteralImages[jjmatchedKind];
t.image = (im == null) ? input_stream.GetImage() : im;
t.beginLine = input_stream.getBeginLine();
t.beginColumn = input_stream.getBeginColumn();
t.endLine = input_stream.getEndLine();
t.endColumn = input_stream.getEndColumn();
return t;
}
int curLexState = 0;
int defaultLexState = 0;
int jjnewStateCnt;
int jjround;
int jjmatchedPos;
int jjmatchedKind;
public final Token getNextToken()
{
int kind;
Token specialToken = null;
Token matchedToken;
int curPos = 0;
EOFLoop :
for (;;)
{
try
{
curChar = input_stream.BeginToken();
}
catch(java.io.IOException e)
{
jjmatchedKind = 0;
matchedToken = jjFillToken();
return matchedToken;
}
switch(curLexState)
{
case 0:
try { input_stream.backup(0);
while (curChar <= 32 && (0x100003600L & (1L << curChar)) != 0L)
curChar = input_stream.BeginToken();
}
catch (java.io.IOException e1) { continue EOFLoop; }
jjmatchedKind = 0x7fffffff;
jjmatchedPos = 0;
curPos = jjMoveStringLiteralDfa0_0();
break;
case 1:
try { input_stream.backup(0);
while (curChar <= 32 && (0x100003600L & (1L << curChar)) != 0L)
curChar = input_stream.BeginToken();
}
catch (java.io.IOException e1) { continue EOFLoop; }
jjmatchedKind = 0x7fffffff;
jjmatchedPos = 0;
curPos = jjMoveStringLiteralDfa0_1();
break;
}
if (jjmatchedKind != 0x7fffffff)
{
if (jjmatchedPos + 1 < curPos)
input_stream.backup(curPos - jjmatchedPos - 1);
if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
{
matchedToken = jjFillToken();
if (jjnewLexState[jjmatchedKind] != -1)
curLexState = jjnewLexState[jjmatchedKind];
return matchedToken;
}
else
{
if (jjnewLexState[jjmatchedKind] != -1)
curLexState = jjnewLexState[jjmatchedKind];
continue EOFLoop;
}
}
int error_line = input_stream.getEndLine();
int error_column = input_stream.getEndColumn();
String error_after = null;
boolean EOFSeen = false;
try { input_stream.readChar(); input_stream.backup(1); }
catch (java.io.IOException e1) {
EOFSeen = true;
error_after = curPos <= 1 ? "" : input_stream.GetImage();
if (curChar == '\n' || curChar == '\r') {
error_line++;
error_column = 0;
}
else
error_column++;
}
if (!EOFSeen) {
input_stream.backup(1);
error_after = curPos <= 1 ? "" : input_stream.GetImage();
}
throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
}
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/BranchNode.java
Index: BranchNode.java
===================================================================
package org.apache.maven.jrcs.rcs;
import java.util.List;
import java.util.LinkedList;
class BranchNode extends Node
{
/**
* the next field in a Branch node points to the next higher
* revision on the same branch
*/
BranchNode(Version vernum, BranchNode next) {
super(vernum, next);
if(vernum == null)
throw new IllegalArgumentException(vernum.toString());
}
public BranchNode getLeafNode() {
BranchNode result = this;
while (result.getNext() != null)
result = (BranchNode) result.getNext();
return result;
}
protected void setRCSNext(Node node) {
super.setRCSNext(node);
if (this._next != null)
this._next._parent = null;
this._next = node;
if (this._next != null)
this._next._parent = this;
}
protected Node deltaRevision() {
return this;
}
protected Node nextInPathTo(Version vernum, boolean soft)
throws NodeNotFoundException
{
Version branchPoint = vernum.getBase(this.version.size());
Version thisBase = this.version.getBase(branchPoint.size());
if (thisBase.isGreaterThan(branchPoint) && !soft)
throw new NodeNotFoundException(vernum); //!!! InternalError, really
if (this.version.equals(vernum))
return null;
else if (this.version.isLessThan(branchPoint))
return _next;
else if (vernum.size() <= this.version.size()) {
if (vernum.size() < this.version.size() || branchPoint.last() == 0)
return _next; // keep going
else
return null;
}
else {
Node branch = getBranch(vernum.at(this.version.size()));
if (branch != null || soft)
return branch;
else
throw new BranchNotFoundException(vernum.getBase(this.version.size()+1));
}
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/BranchNotFoundException.java
Index: BranchNotFoundException.java
===================================================================
package org.apache.maven.jrcs.rcs;
import java.lang.*;
public class BranchNotFoundException extends NodeNotFoundException
{
public BranchNotFoundException() {
super();
}
public BranchNotFoundException(Version v) {
super(v);
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/HeadAlreadySetException.java
Index: HeadAlreadySetException.java
===================================================================
package org.apache.maven.jrcs.rcs;
public class HeadAlreadySetException extends IllegalArgumentException {
public HeadAlreadySetException() {
}
public HeadAlreadySetException(String v) {
super(v);
}
public HeadAlreadySetException(Version v) {
super(v.toString());
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/InvalidBranchVersionNumberException.java
Index: InvalidBranchVersionNumberException.java
===================================================================
package org.apache.maven.jrcs.rcs;
public class InvalidBranchVersionNumberException extends InvalidVersionNumberException {
public InvalidBranchVersionNumberException() {
}
public InvalidBranchVersionNumberException(String v) {
super(v);
}
public InvalidBranchVersionNumberException(Version v) {
super(v);
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/InvalidFileFormatException.java
Index: InvalidFileFormatException.java
===================================================================
package org.apache.maven.jrcs.rcs;
public class InvalidFileFormatException extends RCSException {
public InvalidFileFormatException() {
super();
}
public InvalidFileFormatException(String msg) {
super(msg);
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/InvalidTrunkVersionNumberException.java
Index: InvalidTrunkVersionNumberException.java
===================================================================
package org.apache.maven.jrcs.rcs;
public class InvalidTrunkVersionNumberException
extends InvalidVersionNumberException
{
public InvalidTrunkVersionNumberException() {
}
public InvalidTrunkVersionNumberException(String v) {
super(v);
}
public InvalidTrunkVersionNumberException(Version v) {
super(v);
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/InvalidVersionNumberException.java
Index: InvalidVersionNumberException.java
===================================================================
package org.apache.maven.jrcs.rcs;
public class InvalidVersionNumberException extends IllegalArgumentException {
public InvalidVersionNumberException() {
}
public InvalidVersionNumberException(String v) {
super(v);
}
public InvalidVersionNumberException(Version v) {
super(v.toString());
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/Line.java
Index: Line.java
===================================================================
package org.apache.maven.jrcs.rcs;
class Line {
public Node revision;
public final Object text;
public Line(Node revision, Object text) {
this.text = text;
this.revision = revision;
}
public boolean equals(Object other) {
if (this == other)
return true;
else if (! (other instanceof Line))
return false;
else
return this.text.equals(((Line) other).text);
}
public int hashCode() {
return text.hashCode();
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/Lines.java
Index: Lines.java
===================================================================
package org.apache.maven.jrcs.rcs;
import java.util.List;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.Iterator;
import java.text.Format;
import java.text.MessageFormat;
class Lines extends ArrayList {
public static final Format annotationFormat = new MessageFormat(
"{0,, } ({1} {2, date,dd-MMM-yyyy}):"
);
public Lines() {
}
public Lines(String text) {
this(null, org.apache.maven.jrcs.diff.Diff.stringToArray(text));
}
public Lines(Node release, String text) {
this(release, org.apache.maven.jrcs.diff.Diff.stringToArray(text));
}
public Lines(Object[] text) {
this(null, text);
}
public Lines(Node release, Object[] text) {
for(int i = 0; i < text.length; i++)
super.add(new Line(release, text[i]));
}
public boolean add(Object o) {
return super.add((Line) o);
}
public Object[] toArray() {
return toArray(false);
}
public Object[] toArray(boolean annotate) {
Object[] result = new Object[this.size()];
Iterator r = this.iterator();
int i = 0;
while (r.hasNext()) {
Line l = (Line) r.next();
Object o = l.text;
if (annotate) {
Node rev = l.revision;
o = annotationFormat.format(new Object[] {rev.version, rev._author, rev._date});
}
result[i++] = o;
}
return result;
}
public String toString() {
return toString(false);
}
public String toString(boolean annotate) {
return org.apache.maven.jrcs.diff.Diff.arrayToString(this.toArray(annotate));
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/Node.java
Index: Node.java
===================================================================
package org.apache.maven.jrcs.rcs;
import org.apache.maven.jrcs.diff.*;
import java.util.*;
import java.text.Format;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.text.MessageFormat;
abstract class Node
extends org.apache.maven.jrcs.util.ToString
implements Comparable
{
public final Version version;
protected Date _date = new Date();
protected String _author = System.getProperty("user.name");
protected String _state = "Exp";
protected String _log = "";
protected String _locker = "";
protected Object[] _text;
protected Node _rcsnext;
protected Node _parent;
protected Node _next;
protected TreeMap _branches = null;
protected Phrases _phrases = null;
protected static final Format dateFormatter = new MessageFormat(
"\t{0,number,##00}." +
"{1,number,00}." +
"{2,number,00}." +
"{3,number,00}." +
"{4,number,00}." +
"{5,number,00}"
);
protected static final DateFormat dateFormat = new SimpleDateFormat("yy.MM.dd.HH.mm.ss");
protected static final DateFormat dateFormat2K = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");
protected Node(Node other) {
this(other.version, null);
this._date = other._date;
this._author = other._author;
this._state = other._state;
this._log = other._log;
this._locker = other._locker;
}
protected Node(Version vernum, Node _rcsnext) {
if(vernum == null)
throw new IllegalArgumentException(vernum.toString());
this.version = (Version) vernum.clone();
this.setRCSNext(_rcsnext);
}
static Node newNode(Version vernum, Node _rcsnext)
throws InvalidVersionNumberException
{
if (vernum.isTrunk())
return new TrunkNode(vernum, (TrunkNode) _rcsnext);
else
return new BranchNode(vernum, (BranchNode) _rcsnext);
}
static Node newNode(Version vernum)
throws InvalidVersionNumberException
{
return newNode(vernum, null);
}
public int compareTo(Object other) {
if (other == this)
return 0;
else if (!(other instanceof Node))
return -1;
else
return version.compareTo(((Node) other).version);
}
protected boolean isGhost() {
return version.isGhost() || _text == null;
}
protected BranchNode getBranch(int no) {
if (_branches == null)
return null;
else if (no == 0) {
Integer branchNo = (Integer) _branches.lastKey();
return (BranchNode) (branchNo == null ? null : _branches.get(branchNo));
}
else
return (BranchNode) _branches.get(new Integer(no));
}
protected Node root() {
Node result = this;
while (result._parent != null) {
result = result._parent;
}
return result;
}
protected void setLocker(String user) {
_locker = user.intern();
}
protected void setAuthor(String user) {
_author = user.intern();
}
protected void setDate(int[] value) {
this._date = new GregorianCalendar(value[0] + (value[0] <= 99 ? 1900 : 0),
value[1]-1, value[2],
value[3],value[ 4], value[5]).getTime();
}
protected void setState(String value) {
_state = value;
}
protected void setRCSNext(Node node) {
_rcsnext = node;
}
protected void setLog(String value) {
_log = value;
}
protected void setText(String value) {
this._text = org.apache.maven.jrcs.diff.Diff.stringToArray(value);
}
protected void setText(Object[] value) {
this._text = Arrays.asList(value).toArray();
}
protected void addBranch(BranchNode node) {
if (node.version.isLessThan(this.version))
throw new IllegalArgumentException();
int branchno = node.version.at(this.version.size());
if (_branches == null)
_branches = new TreeMap();
_branches.put(new Integer(branchno), node);
node._parent = this;
}
protected Version nextVersion() {
return this.version.next();
}
protected Version newBranchVersion() {
Version result = new Version(this.version);
if (_branches == null || _branches.size() <= 0)
result.__addBranch(1);
else
result.__addBranch(((Integer) _branches.lastKey()).intValue());
result.__addBranch(1);
return result;
}
protected String getRevision(Version vernum) {
return null;
}
protected Node getNext() {
return _rcsnext;
}
protected Path pathTo(Version vernum)
throws NodeNotFoundException
{
return pathTo(vernum, false);
}
protected Path pathTo(Version vernum, boolean soft)
throws NodeNotFoundException
{
Path path = new Path();
Node target = this;
do {
path.add(target);
target = target.nextInPathTo(vernum, soft);
} while (target != null);
return path;
}
protected abstract Node nextInPathTo(Version vernum, boolean soft)
throws NodeNotFoundException;
protected abstract Node deltaRevision();
protected void patch(List original)
throws InvalidFileFormatException,
NodeNotFoundException,
org.apache.maven.jrcs.diff.PatchFailedException
{
patch(original, false);
}
protected void patch(List original, boolean annotate)
throws InvalidFileFormatException,
NodeNotFoundException,
org.apache.maven.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);
}
public void toString(StringBuffer s) {
toString(s, "\n");
}
public void toString(StringBuffer s, String EOL) {
String EOI = ";"+EOL;
String NLT = EOL + "\t";
s.append(EOL);
s.append(version.toString() + EOL);
s.append("_date");
if (_date != null) {
DateFormat formatter = dateFormat;
Calendar cal = new GregorianCalendar();
cal.setTime(_date);
if (cal.get(Calendar.YEAR) > 1999)
formatter = dateFormat2K;
s.append("\t"+formatter.format(_date));
}
s.append(";\tauthor");
if (_author != null)
s.append(" " + _author);
s.append(";\tstate");
if (_state != null) {
s.append(" ");
s.append(_state);
}
s.append(EOI);
s.append("branches");
if (_branches != null) {
for(Iterator i = _branches.values().iterator(); i.hasNext();) {
Node n = (Node) i.next();
if (n != null)
s.append(NLT + n.version);
}
}
s.append(EOI);
s.append("next\t");
if (_rcsnext != null)
s.append(_rcsnext.version.toString());
s.append(EOI);
}
protected String toText() {
final StringBuffer s = new StringBuffer();
toText(s, "\n");
return s.toString();
}
protected void toText(StringBuffer s, String EOL) {
s.append(EOL + EOL);
s.append(version.toString() + EOL);
s.append("log" + EOL);
s.append(Archive.quoteString(_log));
s.append(EOL);
if (_phrases != null)
s.append(_phrases.toString());
s.append("text" + EOL);
s.append(Archive.quoteString(Diff.arrayToString(_text)+"\n"));
s.append(EOL);
if (_branches != null) {
for(Iterator i = _branches.values().iterator(); i.hasNext();) {
Node n = (Node) i.next();
if (n != null)
n.toText(s, EOL);
}
}
}
protected List getTextLines() {
return getTextLines(new LinkedList());
}
protected List getTextLines(int from, int to) {
return getTextLines(new LinkedList(), from, to);
}
protected List getTextLines(List lines) {
return getTextLines(lines, 0, _text.length);
}
protected List getTextLines(List lines, int from, int to) {
for(int i = from; i < to; i++)
lines.add(new Line(deltaRevision(), _text[i]));
return lines;
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/NodeNotFoundException.java
Index: NodeNotFoundException.java
===================================================================
package org.apache.maven.jrcs.rcs;
import java.lang.*;
class NodeNotFoundException extends IllegalArgumentException
{
public NodeNotFoundException() {
super();
}
public NodeNotFoundException(String msg) {
super(msg);
}
public NodeNotFoundException(Version v) {
super(v.toString());
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/ParseException.java
Index: ParseException.java
===================================================================
package org.apache.maven.jrcs.rcs;
/**
* This exception is thrown when parse errors are encountered.
* You can explicitly create objects of this exception type by
* calling the method generateParseException in the generated
* parser.
*
* You can modify this class to customize your error reporting
* mechanisms so long as you retain the public fields.
*/
public class ParseException extends Exception {
/**
* This constructor is used by the method "generateParseException"
* in the generated parser. Calling this constructor generates
* a new object of this type with the fields "currentToken",
* "expectedTokenSequences", and "tokenImage" set. The boolean
* flag "specialConstructor" is also set to true to indicate that
* this constructor was used to create this object.
* This constructor calls its super class with the empty string
* to force the "toString" method of parent class "Throwable" to
* print the error message in the form:
* ParseException: <result of getMessage>
*/
public ParseException(Token currentTokenVal,
int[][] expectedTokenSequencesVal,
String[] tokenImageVal
)
{
super("");
specialConstructor = true;
currentToken = currentTokenVal;
expectedTokenSequences = expectedTokenSequencesVal;
tokenImage = tokenImageVal;
}
/**
* The following constructors are for use by you for whatever
* purpose you can think of. Constructing the exception in this
* manner makes the exception behave in the normal way - i.e., as
* documented in the class "Throwable". The fields "errorToken",
* "expectedTokenSequences", and "tokenImage" do not contain
* relevant information. The JavaCC generated code does not use
* these constructors.
*/
public ParseException() {
super();
specialConstructor = false;
}
public ParseException(String message) {
super(message);
specialConstructor = false;
}
/**
* This variable determines which constructor was used to create
* this object and thereby affects the semantics of the
* "getMessage" method (see below).
*/
protected boolean specialConstructor;
/**
* This is the last token that has been consumed successfully. If
* this object has been created due to a parse error, the token
* followng this token will (therefore) be the first error token.
*/
public Token currentToken;
/**
* Each entry in this array is an array of integers. Each array
* of integers represents a sequence of tokens (by their ordinal
* values) that is expected at this point of the parse.
*/
public int[][] expectedTokenSequences;
/**
* This is a reference to the "tokenImage" array of the generated
* parser within which the parse error occurred. This array is
* defined in the generated ...Constants interface.
*/
public String[] tokenImage;
/**
* This method has the standard behavior when this object has been
* created using the standard constructors. Otherwise, it uses
* "currentToken" and "expectedTokenSequences" to generate a parse
* error message and returns it. If this object has been created
* due to a parse error, and you do not catch it (it gets thrown
* from the parser), then this method is called during the printing
* of the final stack trace, and hence the correct error message
* gets displayed.
*/
public String getMessage() {
if (!specialConstructor) {
return super.getMessage();
}
String expected = "";
int maxSize = 0;
for (int i = 0; i < expectedTokenSequences.length; i++) {
if (maxSize < expectedTokenSequences[i].length) {
maxSize = expectedTokenSequences[i].length;
}
for (int j = 0; j < expectedTokenSequences[i].length; j++) {
expected += tokenImage[expectedTokenSequences[i][j]] + " ";
}
if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
expected += "...";
}
expected += eol + " ";
}
String retval = "Encountered \"";
Token tok = currentToken.next;
for (int i = 0; i < maxSize; i++) {
if (i != 0) retval += " ";
if (tok.kind == 0) {
retval += tokenImage[0];
break;
}
retval += add_escapes(tok.image);
tok = tok.next;
}
retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn + "." + eol;
if (expectedTokenSequences.length == 1) {
retval += "Was expecting:" + eol + " ";
} else {
retval += "Was expecting one of:" + eol + " ";
}
retval += expected;
return retval;
}
/**
* The end of line string for this machine.
*/
protected String eol = System.getProperty("line.separator", "\n");
/**
* Used to convert raw characters to their escaped version
* when these raw version cannot be used as part of an ASCII
* string literal.
*/
protected String add_escapes(String str) {
StringBuffer retval = new StringBuffer();
char ch;
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i))
{
case 0 :
continue;
case '\b':
retval.append("\\b");
continue;
case '\t':
retval.append("\\t");
continue;
case '\n':
retval.append("\\n");
continue;
case '\f':
retval.append("\\f");
continue;
case '\r':
retval.append("\\r");
continue;
case '\"':
retval.append("\\\"");
continue;
case '\'':
retval.append("\\\'");
continue;
case '\\':
retval.append("\\\\");
continue;
default:
if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
String s = "0000" + Integer.toString(ch, 16);
retval.append("\\u" + s.substring(s.length() - 4, s.length()));
} else {
retval.append(ch);
}
continue;
}
}
return retval.toString();
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/Path.java
Index: Path.java
===================================================================
package org.apache.maven.jrcs.rcs;
import java.util.List;
import java.util.LinkedList;
import java.util.Iterator;
class Path {
protected List _path = new LinkedList();
public Path() {
}
public void add(Node node) {
_path.add(node);
}
public int size() {
return _path.size();
}
public Node last() {
if (size() == 0)
return null;
else
return (Node) _path.get(size()-1);
}
public List patch()
throws InvalidFileFormatException,
org.apache.maven.jrcs.diff.PatchFailedException,
NodeNotFoundException
{
return patch(false);
}
public List patch(boolean annotate)
throws InvalidFileFormatException,
org.apache.maven.jrcs.diff.PatchFailedException,
NodeNotFoundException
{
return patch(new Lines(), annotate);
}
public List patch(List lines)
throws InvalidFileFormatException,
org.apache.maven.jrcs.diff.PatchFailedException,
NodeNotFoundException
{
return patch(lines, false);
}
public List patch(List lines, boolean annotate)
throws InvalidFileFormatException,
org.apache.maven.jrcs.diff.PatchFailedException,
NodeNotFoundException
{
Iterator p = _path.iterator();
// get full text of first node
TrunkNode head = (TrunkNode) p.next();
head.patch0(lines, annotate);
// the rest are patches
while(p.hasNext()) {
Node n = (Node) p.next();
n.patch(lines, annotate);
}
return lines;
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/Phrases.java
Index: Phrases.java
===================================================================
package org.apache.maven.jrcs.rcs;
import java.util.*;
class Phrases extends TreeMap
{
public void toString(StringBuffer s, String EOL) {
Iterator i = keySet().iterator();
while (i.hasNext()) {
String key = i.next().toString();
String value = get(key).toString();
s.append(key.toString());
s.append(" ");
s.append(value);
s.append(EOL);
}
}
public String toString() {
StringBuffer s = new StringBuffer();
toString(s, "\n");
return s.toString();
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/RCSException.java
Index: RCSException.java
===================================================================
package org.apache.maven.jrcs.rcs;
public class RCSException extends Exception {
public RCSException() {
}
public RCSException(String v) {
super(v);
}
public RCSException(Version v) {
super(v.toString());
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/Token.java
Index: Token.java
===================================================================
package org.apache.maven.jrcs.rcs;
/**
* Describes the input token stream.
*/
public class Token {
/**
* An integer that describes the kind of this token. This numbering
* system is determined by JavaCCParser, and a table of these numbers is
* stored in the file ...Constants.java.
*/
public int kind;
/**
* beginLine and beginColumn describe the position of the first character
* of this token; endLine and endColumn describe the position of the
* last character of this token.
*/
public int beginLine, beginColumn, endLine, endColumn;
/**
* The string image of the token.
*/
public String image;
/**
* A reference to the next regular (non-special) token from the input
* stream. If this is the last token from the input stream, or if the
* token manager has not read tokens beyond this one, this field is
* set to null. This is true only if this token is also a regular
* token. Otherwise, see below for a description of the contents of
* this field.
*/
public Token next;
/**
* This field is used to access special tokens that occur prior to this
* token, but after the immediately preceding regular (non-special) token.
* If there are no such special tokens, this field is set to null.
* When there are more than one such special token, this field refers
* to the last of these special tokens, which in turn refers to the next
* previous special token through its specialToken field, and so on
* until the first special token (whose specialToken field is null).
* The next fields of special tokens refer to other special tokens that
* immediately follow it (without an intervening regular token). If there
* is no such token, this field is null.
*/
public Token specialToken;
/**
* Returns the image.
*/
public final String toString()
{
return image;
}
/**
* Returns a new Token object, by default. However, if you want, you
* can create and return subclass objects based on the value of ofKind.
* Simply add the cases to the switch for all those special cases.
* For example, if you have a subclass of Token called IDToken that
* you want to create if ofKind is ID, simlpy add something like :
*
* case MyParserConstants.ID : return new IDToken();
*
* to the following switch statement. Then you can cast matchedToken
* variable to the appropriate type and use it in your lexical actions.
*/
public static final Token newToken(int ofKind)
{
switch(ofKind)
{
default : return new Token();
}
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/TokenMgrError.java
Index: TokenMgrError.java
===================================================================
/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 0.7pre2 */
package org.apache.maven.jrcs.rcs;
public class TokenMgrError extends Error
{
/*
* Ordinals for various reasons why an Error of this type can be thrown.
*/
/**
* Lexical error occured.
*/
static final int LEXICAL_ERROR = 0;
/**
* An attempt wass made to create a second instance of a static token manager.
*/
static final int STATIC_LEXER_ERROR = 1;
/**
* Tried to change to an invalid lexical state.
*/
static final int INVALID_LEXICAL_STATE = 2;
/**
* Detected (and bailed out of) an infinite loop in the token manager.
*/
static final int LOOP_DETECTED = 3;
/**
* Indicates the reason why the exception is thrown. It will have
* one of the above 4 values.
*/
int errorCode;
/**
* Replaces unprintable characters by their espaced (or unicode escaped)
* equivalents in the given string
*/
protected static final String addEscapes(String str) {
StringBuffer retval = new StringBuffer();
char ch;
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i))
{
case 0 :
continue;
case '\b':
retval.append("\\b");
continue;
case '\t':
retval.append("\\t");
continue;
case '\n':
retval.append("\\n");
continue;
case '\f':
retval.append("\\f");
continue;
case '\r':
retval.append("\\r");
continue;
case '\"':
retval.append("\\\"");
continue;
case '\'':
retval.append("\\\'");
continue;
case '\\':
retval.append("\\\\");
continue;
default:
if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
String s = "0000" + Integer.toString(ch, 16);
retval.append("\\u" + s.substring(s.length() - 4, s.length()));
} else {
retval.append(ch);
}
continue;
}
}
return retval.toString();
}
/**
* Returns a detailed message for the Error when it is thrown by the
* token manager to indicate a lexical error.
* Parameters :
* EOFSeen : indicates if EOF caused the lexicl error
* curLexState : lexical state in which this error occured
* errorLine : line number when the error occured
* errorColumn : column number when the error occured
* errorAfter : prefix that was seen before this error occured
* curchar : the offending character
* Note: You can customize the lexical error message by modifying this method.
*/
private static final String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
return("Lexical error at line " +
errorLine + ", column " +
errorColumn + ". Encountered: " +
(EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
"after : \"" + addEscapes(errorAfter) + "\"");
}
/**
* You can also modify the body of this method to customize your error messages.
* For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
* of end-users concern, so you can return something like :
*
* "Internal Error : Please file a bug report .... "
*
* from this method for such cases in the release version of your parser.
*/
public String getMessage() {
return super.getMessage();
}
/*
* Constructors of various flavors follow.
*/
public TokenMgrError() {
}
public TokenMgrError(String message, int reason) {
super(message);
errorCode = reason;
}
public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/TrunkNode.java
Index: TrunkNode.java
===================================================================
package org.apache.maven.jrcs.rcs;
import java.util.List;
import java.util.LinkedList;
class TrunkNode extends Node
{
TrunkNode(TrunkNode other) {
super(other);
}
/**
* the next field in a Trunk node points to the immediate
* previos revision
*/
TrunkNode(Version vernum, TrunkNode next)
throws InvalidTrunkVersionNumberException
{
super(vernum, next);
if (vernum.size() > 2)
throw new InvalidTrunkVersionNumberException(vernum);
}
protected void setRCSNext(Node node) {
super.setRCSNext(node);
if (this._parent != null)
this._parent._next = null;
this._parent = node;
if (this._parent != null)
this._parent._next = this;
}
protected Node deltaRevision() {
return (_next != null ? _next : this);
}
protected Node nextInPathTo(Version vernum, boolean soft)
throws NodeNotFoundException
{
Version branchPoint = vernum.getBase(2);
if (this.version.isLessThan(branchPoint)) {
if (soft)
return null;
else
throw new NodeNotFoundException(vernum);
}
Version thisBase = this.version.getBase(branchPoint.size());
if (thisBase.isGreaterThan(branchPoint))
return _parent;
else if (vernum.size() > this.version.size()) {
Node branch = getBranch(vernum.at(this.version.size()));
if (branch != null || soft)
return branch;
else
throw new BranchNotFoundException(vernum.getBase(this.version.size()+1));
}
else
return null;
}
/**
* Provide the initial patch.
* Used only for head nodes.
* @param original Where to add the patch to.
* @param annotate True if the lines should be annotated with version numbers.
*/
protected void patch0(List original, boolean annotate)
throws InvalidFileFormatException,
NodeNotFoundException,
org.apache.maven.jrcs.diff.PatchFailedException
{
Node root = this.root();
for (int it = 0; it < _text.length; it++) {
original.add(new Line(root, _text[it]));
}
if (annotate && _parent != null)
_parent.pathTo(root.version).patch(original, true);
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/Version.java
Index: Version.java
===================================================================
package org.apache.maven.jrcs.rcs;
import java.util.*;
public class Version
extends org.apache.maven.jrcs.util.ToString
implements Cloneable, Comparable
{
int[] numbers = new int[0];
public Version(int major) {
numbers = new int[]{major};
}
public Version(int major, int minor) {
numbers = new int[]{major, minor};
}
public Version(Integer[] num) {
numbers = new int[num.length];
for(int i = 0; i < num.length; i++)
numbers[i] = num[i].intValue();
}
public Version(int[] num) {
numbers = (int[]) num.clone();
}
public Version(String v) throws InvalidVersionNumberException {
if (v.endsWith("."))
v = v + "0";
StringTokenizer t = new StringTokenizer(v, ".");
int count = t.countTokens();
if (even(count) && v.endsWith(".0"))
count--; // allow a .0 ending only in branch revisions
numbers = new int[count];
for(int i = 0; i < count; i++) {
try {
numbers[i] = Integer.parseInt(t.nextToken());
} catch(NumberFormatException e) {
throw new InvalidVersionNumberException(v);
}
}
}
public Version(Version v) {
this.numbers = (int[]) v.numbers.clone();
if (!Arrays.equals(this.numbers, v.numbers))
throw new java.lang.IllegalStateException(numbers.toString());
}
public Version() {
}
public Object clone()
{
return new Version(this);
}
public int[] getNumbers() {
return (int[]) this.numbers.clone();
}
public int compareVersions(Version ver) {
int[] nthis = this.numbers;
int[] nthat = ver.numbers;
int i;
for(i = 0; i < nthis.length; i++) {
if (i >= nthat.length || nthis[i] > nthat[i])
return 1;
else if (nthis[i] < nthat[i])
return -1;
}
// all matched up to i-1
if (nthat.length > i)
return -1;
else
return 0;
}
public int compareTo(Object other) {
if (other == this)
return 0;
else if (!(other instanceof Version))
throw new IllegalArgumentException(other.toString());
else {
Version otherver = (Version) other;
if (this.size() < otherver.size())
return -1;
else if (this.size() > otherver.size())
return 1;
else
return -toString().compareTo(otherver.toString());
}
}
public boolean isGreaterThan(Version ver) {
return compareVersions(ver) > 0;
}
public boolean isGreaterOrEqualThan(Version ver) {
return compareVersions(ver) >= 0;
}
public boolean isLessThan(Version ver) {
return compareVersions(ver) < 0;
}
public boolean isLessOrEqualThan(Version ver) {
return compareVersions(ver) <= 0;
}
public boolean equals(Object o) {
if (this == o)
return true;
else if (! (o instanceof Version) )
return false;
else if (hashCode() != o.hashCode())
return false;
else
return compareTo((Version) o) == 0;
}
public int hashCode() {
return toString().hashCode();
}
public int at(int pos) {
return numbers[pos];
}
public int last() {
return at(size()-1);
}
public Version getBase(int positions) {
positions = (positions > numbers.length ? numbers.length : positions);
int[] result = new int[positions];
System.arraycopy(this.numbers, 0, result, 0, positions);
return new Version(result);
}
public Version getBranchPoint() {
return getBase(size() - 1);
}
public Version next() {
Version result = new Version(this);
result.numbers[this.numbers.length-1] = this.last()+1;
return result;
}
protected void __addBranch(Integer branch) {
__addBranch(branch.intValue());
}
protected void __addBranch(int branch) {
int[] newnum = new int[numbers.length + 1];
System.arraycopy(this.numbers, 0, newnum, 0, numbers.length);
newnum[numbers.length] = branch;
this.numbers = newnum;
}
public Version newBranch(int branch) {
int[] newnum = new int[numbers.length + 1];
System.arraycopy(this.numbers, 0, newnum, 0, numbers.length);
newnum[numbers.length] = branch;
Version result = new Version();
result.numbers = newnum;
return result;
}
public int size() {
return numbers.length;
}
public boolean isTrunk() {
return (size() >= 1) && (size() <= 2);
}
public boolean isBranch() {
return size() > 2;
}
public boolean isRevision() {
return even();
}
public boolean isGhost() {
for(int i = 0; i < size(); i++)
if (numbers[i] <= 0)
return true;
return false;
}
public boolean even(int n) {
return n % 2 == 0;
}
public boolean even() {
return even(size());
}
public boolean odd(int n) {
return !even(n);
}
public boolean odd() {
return !even();
}
public void toString(StringBuffer s) {
if (size() > 0) {
s.append(Integer.toString(numbers[0]));
for(int i = 1; i < numbers.length; i++) {
s.append(".");
s.append(Integer.toString(numbers[i]));
}
}
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/util/ToString.java
Index: ToString.java
===================================================================
package org.apache.maven.jrcs.util;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/**
* This class delegates handling of the to a StringBuffer based version.
*/
public abstract class ToString {
public ToString() {
}
public String toString() {
StringBuffer s = new StringBuffer();
toString(s);
return s.toString();
}
public abstract void toString(StringBuffer s);
}
1.1 jakarta-turbine-maven/src/test/org/apache/maven/jrcs/diff/DiffTest.java
Index: DiffTest.java
===================================================================
package org.apache.maven.jrcs.diff;
import junit.framework.*;
public class DiffTest extends TestCase {
public DiffTest(String testName) {
super(testName);
}
public static Test suite() {
return new TestSuite(DiffTest.class);
}
Object[] empty = new Object[] {};
Object[] original = new String[] {
"[1] one",
"[2] two",
"[3] three",
"[4] four",
"[5] five",
"[6] six",
"[7] seven",
"[8] eight",
"[9] nine"
};
// lines 3 and 9 deleted
Object[] rev1 = new String[] {
"[1] one",
"[2] two",
"[4] four",
"[5] five",
"[6] six",
"[7] seven",
"[8] eight",
};
// lines 7 and 8 changed, 9 deleted
Object[] rev2 = new String[] {
"[1] one",
"[2] two",
"[3] three",
"[4] four",
"[5] five",
"[6] six",
"[7] seven revised",
"[8] eight revised",
};
public void testCompare() {
assertTrue(!Diff.compare(original, empty));
assertTrue(!Diff.compare(empty, original));
assertTrue(Diff.compare(empty, empty));
assertTrue(Diff.compare(original, original));
}
public void testDeleteAll()
throws DifferentiationFailedException, PatchFailedException
{
Revision revision = Diff.diff(original, empty);
assertEquals(revision.size(), 1);
assertEquals(revision.getDelta(0).getClass(), DeleteDelta.class);
assertTrue(Diff.compare(revision.patch(original), empty));
}
public void testTwoDeletes()
throws DifferentiationFailedException, PatchFailedException
{
Revision revision = Diff.diff(original, rev1);
assertEquals(revision.size(), 2);
assertEquals(revision.getDelta(0).getClass(), DeleteDelta.class);
assertEquals(revision.getDelta(1).getClass(), DeleteDelta.class);
assertTrue(Diff.compare(revision.patch(original), rev1));
assertEquals("3d2\n" +
"< [3] three\n" +
"9d7\n" +
"< [9] nine\n"
, revision.toString());
}
public void testChangeAtTheEnd()
throws DifferentiationFailedException, PatchFailedException
{
Revision revision = Diff.diff(original, rev2);
assertEquals(1, revision.size());
assertEquals(ChangeDelta.class, revision.getDelta(0).getClass());
assertTrue(Diff.compare(revision.patch(original), rev2));
assertEquals("d7 3\n" +
"a7 2\n" +
"[7] seven revised\n" +
"[8] eight revised\n",
revision.toRCSString());
}
public void testPatchFailed()
throws DifferentiationFailedException
{
try {
Revision revision = Diff.diff(original, rev2);
assertTrue(!Diff.compare(revision.patch(rev1), rev2));
fail("PatchFailedException not thrown");
}
catch(PatchFailedException e) {
}
}
public void testPreviouslyFailedShuffle()
throws DifferentiationFailedException, PatchFailedException
{
Object[] orig = new String[] {
"[1] one",
"[2] two",
"[3] three",
"[4] four",
"[5] five",
"[6] six"
};
Object[] rev = new String[] {
"[3] three",
"[1] one",
"[5] five",
"[2] two",
"[6] six",
"[4] four"
};
Revision revision = Diff.diff(orig, rev);
Object[] patched = revision.patch(orig);
assertTrue(Diff.compare(patched, rev));
}
public void testEdit5()
throws DifferentiationFailedException, PatchFailedException
{
Object[] orig = new String[] {
"[1] one",
"[2] two",
"[3] three",
"[4] four",
"[5] five",
"[6] six"
};
Object[] rev = new String[] {
"one revised",
"two revised",
"[2] two",
"[3] three",
"five revised",
"six revised",
"[5] five"
};
Revision revision = Diff.diff(orig, rev);
Object[] patched = revision.patch(orig);
assertTrue(Diff.compare(patched, rev));
}
public void testShuffle()
throws DifferentiationFailedException, PatchFailedException
{
Object[] orig = new String[] {
"[1] one",
"[2] two",
"[3] three",
"[4] four",
"[5] five",
"[6] six"
};
for(int seed = 0; seed < 10; seed++) {
Object[] shuffle = Diff.shuffle(orig, seed);
Revision revision = Diff.diff(orig, shuffle);
Object[] patched = revision.patch(orig);
if (!Diff.compare(patched, shuffle)) {
fail("iter "+ seed + " revisions differ after patch");
}
}
}
public void testRandomEdit()
throws DifferentiationFailedException, PatchFailedException
{
Object[] orig = original;
for (int seed = 0; seed < 10; seed++) {
Object[] random = Diff.randomEdit(orig, seed);
Revision revision = Diff.diff(orig, random);
Object[] patched = revision.patch(orig);
if (!Diff.compare(patched, random)) {
fail("iter " + seed + " revisions differ after patch");
}
orig = random;
}
}
}
1.1 jakarta-turbine-maven/src/test/org/apache/maven/jrcs/rcs/ArchiveTest.java
Index: ArchiveTest.java
===================================================================
package org.apache.maven.jrcs.rcs;
import org.apache.maven.jrcs.diff.Diff;
import junit.framework.*;
public class ArchiveTest extends TestCase {
public ArchiveTest(String testName) {
super(testName);
}
public static Test suite() {
return new TestSuite(ArchiveTest.class);
}
Object[] v1_1 = new String[] {
"[1] one",
"[2] two",
"[3] three",
"[4] four",
"[5] five",
"[6] six",
};
Object[] v1_2 = new String[] {
"[1] one",
"[2] two",
"[3] three",
"[3.1]", // inserted this
"[4] four",
"[5] five"
// deleted [6]
};
Object[] v1_3 = new String[] {
"[1] one changed",
"[2] two",
"[3] three",
"[3.1]",
"[4] four",
"[5] five"
};
Object[] v1_20 = new String[] {
"[1:1.20] one changed",
"[3] three",
"[3.1]",
"[5:1.20] five"
};
Object[] v1_2_1_1 = new String[] {
"[1] one",
"[2] two",
"[2.1]",
"[3] three",
"[3.1]",
"[4] four changed",
"[5] five",
"[5.1]"
};
Object[] v1_2_1_2 = new String[] {
"[1:1.2.1.1] one",
"[2.1]",
"[3] three",
"[3.1]",
"[4] four changed",
"[5:1.2.1.1] five",
"[5.1]"
};
Object[] v1_2_8_2 = new String[] {
"[1:1.2.8.1] one",
"[2.1]",
"[3] three",
"[3.1]",
"[4] four changed",
"[5:1.2.8.1] five",
"[5.1]"
};
Object[] v1_2_8_4 = new String[] {
"[1:1.2.8.1] one",
"[2.1]",
"[3.1:1.2.8.2]",
"[4] four changed",
"[5:1.2.8.1] five",
"[5.1]"
};
Object[] v1_2_8_5 = new String[] {
"[1:1.2.8.5] one"
};
Archive archive;
public void setUp() {
archive = new Archive(v1_1, "A simple test file\n");
}
public void testEmptyArchive() {
try {
Object[] rev = new Archive().getRevision();
if (rev != null)
fail("empty archive, exception should be thrown");
}
catch(Exception e)
{}
}
public void testAdd1_1()
throws org.suigeneris.diff.DiffException,
org.suigeneris.rcs.RCSException
{
Object[] rev = archive.getRevision();
assertTrue(Diff.compare(v1_1, rev));
assertNull(archive.addRevision(v1_1, "should not be added"));
assertEquals(new Version("1.1"), archive.getRevisionVersion());
assertEquals(new Version("1.1"), archive.getRevisionVersion("1."));
assertNull(archive.getRevisionVersion("2"));
assertNull(archive.getRevisionVersion("1.2.1"));
}
public void testAdd1_2()
throws org.suigeneris.diff.DiffException,
org.suigeneris.rcs.RCSException
{
testAdd1_1();
archive.addRevision(v1_2, "Added 3.1, deleted 6\n");
Object[] rev = archive.getRevision();
assertEquals("1.2", archive._head.version.toString());
assertEquals(Diff.arrayToString(v1_2), Diff.arrayToString(rev));
assertNull(archive.addRevision(v1_2, "should not be added"));
assertEquals(new Version("1.2"), archive.getRevisionVersion());
assertEquals(new Version("1.2"), archive.getRevisionVersion("1."));
assertNull(archive.getRevisionVersion("2"));
assertNull(archive.getRevisionVersion("1.2.1"));
}
public void testAdd1_3()
throws org.suigeneris.diff.DiffException,
org.suigeneris.rcs.RCSException
{
testAdd1_2();
archive.addRevision(v1_3, "Changed 1\n");
Object[] rev = archive.getRevision();
assertTrue(Diff.compare(v1_3, rev));
assertNull(archive.addRevision(v1_3, "should not be added"));
assertEquals(new Version("1.3"), archive.getRevisionVersion());
assertEquals(new Version("1.3"), archive.getRevisionVersion("1"));
assertNull(archive.getRevisionVersion("2"));
assertNull(archive.getRevisionVersion("1.2.1"));
}
public void testAdd1_2_1()
throws org.suigeneris.diff.DiffException,
org.suigeneris.rcs.RCSException
{
testAdd1_3();
archive.addRevision(v1_2_1_1, "1.2.1", "Added 2.1, changed 4, added 5.1\n");
String filestr = archive.toString();
Object[] file = Diff.stringToArray(filestr);
String diff = Diff.diff(file, sampleFile).toRCSString();
String delta = Diff.arrayToString(deltaOverDates)+"\n";
assertEquals("delta over dates", delta , diff);
Object[] rev = archive.getRevision("1.2.1");
assertTrue("diffs equal", Diff.compare(v1_2_1_1, rev));
assertNull("should not be added", archive.addRevision(v1_2_1_1, "1.2.1", "should not be added"));
assertEquals("dot", new Version("1.2.1.1"), archive.getRevisionVersion("1.2."));
assertEquals("zero", new Version("1.2.1.1"), archive.getRevisionVersion("1.2.0"));
assertEquals(new Version("1.2.1.1"), archive.getRevisionVersion("1.2.1"));
assertEquals(new Version("1.2.1.1"), archive.getRevisionVersion("1.2.1"));
assertNull(archive.getRevisionVersion("2"));
assertNull(archive.getRevisionVersion("1.3.1"));
assertNull(archive.getRevisionVersion("1.2.1.2"));
assertNull(archive.getRevisionVersion("1.2.2"));
}
public void testBranch()
throws org.suigeneris.diff.DiffException,
org.suigeneris.rcs.RCSException
{
testAdd1_3();
archive.setBranch("1.2.0");
archive.addRevision(v1_2_1_1, "Added 2.1, changed 4\n");
String file = archive.toString();
Object[] rev = archive.getRevision("1.2.1.1");
assertTrue(Diff.compare(v1_2_1_1, rev));
Version v;
v = archive.addRevision(v1_2_1_2, "1.2.0", "Arbitrary revision number");
assertEquals("1.2.1.2", v.toString());
v = archive.addRevision(v1_2_8_2, "1.2.8.2", "Arbitrary revision number");
assertEquals("1.2.8.2", v.toString());
try {
v = archive.addRevision(v1_2_8_4, "1.2.8.1", "Added to arbitrary branch");
fail("could add revision 1.2.8.1 after having added 1.2.8.2");
} catch(InvalidVersionNumberException e)
{}
v = archive.addRevision(v1_2_8_4, "1.2.8.4", "Added to arbitrary branch");
assertEquals("1.2.8.4", v.toString());
v = archive.addRevision(v1_2_8_5, "1.2.0", "Added to arbitrary branch");
assertEquals("1.2.8.5", v.toString());
assertEquals(new Version("1.2.8.5"), archive.getRevisionVersion());
assertEquals(".8", new Version("1.2.8.5"), archive.getRevisionVersion("1.2.8"));
assertEquals(new Version("1.2.8.5"), archive.getRevisionVersion("1.2."));
assertEquals(new Version("1.2.8.5"), archive.getRevisionVersion("1.2.0"));
assertNull(archive.getRevisionVersion("1.2.8.6"));
assertNull(archive.getRevisionVersion("1.2.3"));
assertNull(archive.getRevisionVersion("1.2.9"));
}
public void testInvalidBranch()
throws org.suigeneris.diff.DiffException,
org.suigeneris.rcs.RCSException
{
testAdd1_1();
try {
archive.setBranch("1.3.1");
fail("succeeded with invalid branch");
}
catch(InvalidVersionNumberException e)
{}
}
String[] sampleFile = {
"head\t1.3;",
"access;",
"symbols;",
"locks; strict;",
"comment\t@# @;",
"",
"",
"1.3",
"date\t99.08.24.16.58.59;\tauthor juanca;\tstate Exp;",
"branches;",
"next\t1.2;",
"",
"1.2",
"date\t99.08.24.16.57.54;\tauthor juanca;\tstate Exp;",
"branches",
"\t1.2.1.1;",
"next\t1.1;",
"",
"1.1",
"date\t99.08.24.16.56.51;\tauthor juanca;\tstate Exp;",
"branches;",
"next\t;",
"",
"1.2.1.1",
"date\t99.08.24.17.00.30;\tauthor juanca;\tstate Exp;",
"branches;",
"next\t;",
"",
"",
"desc",
"@A simple test file",
"@",
"",
"",
"1.3",
"log",
"@Changed 1",
"@",
"text",
"@[1] one changed",
"[2] two",
"[3] three",
"[3.1]",
"[4] four",
"[5] five",
"@",
"",
"",
"1.2",
"log",
"@Added 3.1, deleted 6",
"@",
"text",
"@d1 1",
"a1 1",
"[1] one",
"@",
"",
"",
"1.2.1.1",
"log",
"@Added 2.1, changed 4, added 5.1",
"@",
"text",
"@a2 1",
"[2.1]",
"d5 1",
"a5 1",
"[4] four changed",
"a6 1",
"[5.1]",
"@",
"",
"",
"1.1",
"log",
"@Initial revision",
"@",
"text",
"@d4 1",
"a6 1",
"[6] six",
"@"
};
String[] deltaOverDates = {
"d9 1",
"a9 1",
"date\t99.08.24.16.58.59;\tauthor juanca;\tstate Exp;",
"d14 1",
"a14 1",
"date\t99.08.24.16.57.54;\tauthor juanca;\tstate Exp;",
"d20 1",
"a20 1",
"date\t99.08.24.16.56.51;\tauthor juanca;\tstate Exp;",
"d25 1",
"a25 1",
"date\t99.08.24.17.00.30;\tauthor juanca;\tstate Exp;"
};
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: cvs commit:
jakarta-turbine-maven/src/test/org/apache/maven/jrcs/rcs ArchiveTest.java
Posted by Jason van Zyl <jv...@zenplex.com>.
On Wed, 2002-02-20 at 11:57, Kurt Schrader wrote:
>
> On Wednesday, February 20, 2002, at 11:20 AM, jvanzyl@apache.org wrote:
>
> > 1.1 jakarta-turbine-
> > maven/src/java/org/apache/maven/jrcs/rcsp.java
> >
> > Index: rcsp.java
> > ===================================================================
> > package org.apache.maven.jrcs;
>
> <cut>
>
> > static String edited =
> > " *\n"+
> > " * This software is distributed under the GNU General Public
> > License.\n"+
> > " * See the file COPYING.TXT for details.\n"+
> > "randomEdit[1][0]\n"+
> > "randomEdit[1][2]";
>
> This doesn't seem to be used anywhere, so perhaps it should just be
> removed.
Go ahead and nuke it :-)
> -Kurt
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
jvz.
Jason van Zyl
jvanzyl@apache.org
http://tambora.zenplex.org
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: cvs commit: jakarta-turbine-maven/src/test/org/apache/maven/jrcs/rcs ArchiveTest.java
Posted by Kurt Schrader <ks...@engin.umich.edu>.
On Wednesday, February 20, 2002, at 11:20 AM, jvanzyl@apache.org wrote:
> 1.1 jakarta-turbine-
> maven/src/java/org/apache/maven/jrcs/rcsp.java
>
> Index: rcsp.java
> ===================================================================
> package org.apache.maven.jrcs;
<cut>
> static String edited =
> " *\n"+
> " * This software is distributed under the GNU General Public
> License.\n"+
> " * See the file COPYING.TXT for details.\n"+
> "randomEdit[1][0]\n"+
> "randomEdit[1][2]";
This doesn't seem to be used anywhere, so perhaps it should just be
removed.
-Kurt
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>