ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Keith Hall <keith.h...@granada-learning.com>
Subject and and cvs
Date Thu, 04 May 2006 10:59:27 GMT
I'm hoping someone else has done this before or something similar
I'm using ant to generate a report showing changes to files between tags within our cvs repository.

This for example works
    <target name="tagprompts" >

         <input
            message="Please Enter Start Tag:"
            addproperty="starttag"
            defaultvalue="tw2_v1_0b1"
          />
          <input
            message="Please Enter End Tag:"
            addproperty="endtag"
            defaultvalue="tw2_v1_0b1"
          />
    </target>
    <target name="tagverdiff" depends="tagprompts">
        <echo message="s='${starttag}' e='${endtag}'"/>
        <cvstagdiff cvsRoot="${cvsroot}"
            cvsRsh="ssh"
            passfile=".cvspass"
            destfile="tagdiff.xml"
            package="${package}"
            startTag="${starttag}"
            endTag="${endtag}"
        />
    </target>

    <target name="tagverdiffreport" depends="tagverdiff">
        <style in="tagdiff.xml"
            out="tagdiff.html"
            style="tagdiff.xsl">
            <param name="title" expression="Ant Diff"/>
            <param name="module" expression="${package}"/>
            <param name="cvsweb" expression="${cvsweb}"/>
        </style>
    </target>

but relies on users knowing the tags.

This doesn't.

It creates a txt file for all the tags used on my build file which I happen to know has been
there from day one and give me a Dialog Box with the list of tags, defaulting to second last
and last.

    <property name="chosenstarttag" value=""/>
    <property name="chosenendtag" value=""/>
    <property name="checkvalue" value=""/>
        <!--create list tags -->
    <target name="cvstags">
        <cvs output="status.txt">
            <commandline>
                <argument line="-q status -v build.xml"/>
            </commandline>
        </cvs>
    </target>
<target name="getchosentags" depends="cvstags">

        <script language="javascript">
        <![CDATA[
        importPackage(Packages.javax.swing);
        importPackage(Packages.java.io);
        importPackage(Packages.java.util);
        try{

            var lines="";
            var fileReader = new BufferedReader(FileReader(new File("status.txt")));    ///home/keithh/IdeaProjects/testwisev2_10/testwisev2/
            var line = fileReader.readLine();
            var startTags = false;
            var lineArray = new Array();
            while(line !=null){
                if (line.indexOf("Existing Tags:")>-1){
                    startTags = true;
                    line = fileReader.readLine();
                }
                if(startTags && line!=null){
                    var lineTag = line.indexOf(" ");
                    if(lineTag > -1){

                        lineArray.push(line.substring(0,lineTag));
                    }
                }
                line = fileReader.readLine();
            }
            var s = JOptionPane.showInputDialog(
                    null,
                    "Get start tag from drop down list",
                    "Select Start tag",
                    JOptionPane.PLAIN_MESSAGE,
                    null,
                    lineArray,
                    lineArray[1]);

            if(s!=null){
                var ss = '';
                for(i = 0; i<s.toString().length(); i++){
                    ss=ss+String.fromCharCode(s.charAt(i));
                }
                //ss=''+s.toString();
                //project.setProperty('chosenstarttag',ss);
                project.setProperty('chosenstarttag',s);
            }
            var e = JOptionPane.showInputDialog(
                    null,
                    "Get end tag from drop down list",
                    "Select End tag",
                    JOptionPane.PLAIN_MESSAGE,
                    null,
                    lineArray,
                    lineArray[0]);

            if(e!=null){
                var ee = '';
                for(i = 0; i<e.toString().length(); i++){
                    ee=ee+String.fromCharCode(e.charAt(i));
                }
                //ee=''+e.toString();
                //project.setProperty('chosenendtag',ee);	
                project.setProperty('chosenendtag',e);
            }

            //project.setProperty('chosenstarttag','tw2_v1_1b7');
            //project.setProperty('chosenendtag','tw2_v1_1b8');

            echochosentag = project.createTask("echo");
            echochosentag.setMessage(ss.length + " " + typeof(e) + " " + typeof(ee) + "  "
 + typeof(project.getProperty('chosenstarttag')) + " selected tags project.getProperty('chosenstarttag')
= '" + project.getProperty('chosenstarttag') + "' project.getProperty('chosenendtag') = '"
+ project.getProperty('chosenendtag') + "'");
          
            getchosentags.addTask(echochosentag);
            echochosentag.perform()

            var tagdiff = project.createTask("cvstagdiff");
            tagdiff.setCvsRoot(project.getProperty('cvsroot'));
            tagdiff.setCvsRsh('ssh');
            tagdiff.setPassfile(new File('.cvspass'));
            tagdiff.setDestFile(new File('tagdiff.xml'));
            tagdiff.setStartTag(project.getProperty('chosenstarttag'));
            tagdiff.setEndTag(project.getProperty('chosenendtag'));
            //tagdiff.setStartTag(ss);
            //tagdiff.setEndTag(ee);
            tagdiff.setPackage(project.getProperty('package'))
            tagdiff.execute();

        }catch(e){
            echochosentag.setMessage("exception " + e);
        }


        ]]>
        </script>
</target>


I see  the response 

"duplicate key found for `y'" from cvs


If I take out the comments for example on the lines
            //project.setProperty('chosenstarttag','tw2_v1_1b7');
            //project.setProperty('chosenendtag','tw2_v1_1b8');
then the script works for these hardcoded values.
So the only thing that seems to be stopping it is some internal representation of the value
returned from  var s = JOptionPane.showInputDialog command. 
I've checked that the value is correct and cast it from object to string and parsed each chararacter
etc as you can probably see in the commented sections of the code. The value that is passed
into the setStartTag and setEndTag looks correct.
I've also created another target and taken out the tagdiff creation from the javascript like
this


    <target name="chosentagverdiff" depends="getchosentags">
        <echo message="s='${chosenstarttag}' e='${chosenendtag}'"/>
        <cvstagdiff cvsRoot="${cvsroot}"
            cvsRsh="ssh"
            passfile=".cvspass"
            destfile="tagdiff.xml"
            package="${package}"
            startTag="${chosenstarttag}"
            endTag="${chosenendtag}"
        />
    </target> 


It just keeps screwing up.

Any ideas please

Cheers


Keith Hall

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message