xmlclearcasebuildforge

Handle spaces in xml interface parameter passing


We have a system that contains spaces in some of its path names. Since they are part of the core code, they cannot be renamed. Dealing with this in tools that invoke command line commands was just a matter of adding sets of double quotes.

However, I haven't found a way to deal with this in the xml code that's used by the Build Forge adaptor.

For example, when attempting to have the adaptor execute the following command:

cleartool describe "foo bar"@@\main\1

The code would like the following:

<match pattern="^(.*?)\@\@(.*?)$"> 

<run command="cc_describe" params="$1 $2"/>

<command name="cc_describe">
    <execute>
         pushd cleartool desc $1@@$2;
    </execute>
</command>

Assume $1 = "foo bar" and $2 = "\main\1"

At execution time, the second parameter is - of course - ignored because the first one contains a space:

Preparsing Command Set: [pushd cleartool desc $1@@$2], using Params: 'foo bar main\1'.
Command Set Parsed To: [pushd cleartool desc "foo@@bar"] 

I tried fixing this by adding double quotes in the calling command:

<run command="cc_describe" params="&quot;$1&quot; $2"/>

The double quotes make it into the command, but do not make a difference:

Preparsing Command Set: [pushd cleartool desc $1@@$2], using Params: '"foo bar" \main\1'.
Command Set Parsed To: [pushd cleartool desc "foo@@bar"] 

Attempted solution: move @@ to the calling command, remove it from the receiving command and add additional parameter (to be able to handle 1 space):

<run command="cc_describe" params="$1@@$2"/>

<command name="cc_describe">
    <execute>
         pushd cleartool desc $1$2$3;
   </execute> 
</command>

Execution result:

Preparsing Command Set: [pushd cleartool desc $1@@$2$3], using Params: 'foo bar \main\1'.
Command Set Parsed To: [pushd cleartool desc "foobar@@\main\1"] 

Solution

  • I got it to work using @VonC suggestions. It's a roundabout way of doing it but it does work! Still need to make some improvements to it (such as not using the same temp files).

    Here's the relevant sections of the Build Forge ClearCase code changes adaptor.

    <run command="cc_changes" params="$LAST_RUN $DEV_VIEW $VOB_TAG $DEV_STREAM" server="" dir="/" timeout="720"/>
    
    <command name="cc_changes">
        <execute>
            cleartool startview $2
            cleartool mount $3
            <!-- Store the output of the find command in a text file -->
            pushd \\view${DirSep}$2 &amp;&amp; cleartool find .$3 -all -cview -version "{created_since($1)" -print &gt; %temp%\changes.txt
        <!-- Change each space to a = -->
        perl -pi~ -e "s/ /=/g" %temp%\changes.txt
        type %temp%\changes.txt
        </execute>
        <!-- Loop through the results and call the cc_describe command for each entry -->
        <resultsblock>
            <match pattern="^(.*?)\@\@(.*?)$">
                <run command="cc_describe" params="${DEV_VIEW} $1 $2" server="" dir="/" timeout="720"/>
            </match>
        </resultsblock>
    </command>
    
    <command name="cc_describe">
        <execute>
            <!-- Store the cleartool subcommand and the file name in a text file --> 
            echo desc -fmt "${ExpVar}En:${ExpVar}Vn:${ExpVar}Nd:${ExpVar}u:${ExpVar}c" "$2@@$3" &gt; %temp%\change.txt
            <!-- Change the =s back to spaces -->
            perl -pi~ -e "s/=/ /g"  %temp%\change.txt
            <!-- Pipe the text file into the cleartool command -->
            pushd \\view${DirSep}$1 &amp;&amp; cleartool &lt; %temp%\change.txt
        </execute>
        <resultsblock>
            <!-- For each match in the output, we add information to the BOM -->
            <match pattern="^(.*?):(.*?):(.*?):(.*?):(.*?)$">
                <bom category="Source" section="changes">
                    <field name="file" text="$1"/>
                    <field name="version" text="$2"/>
                    <field name="date" text="$3"/>
                    <field name="user" text="$4"/>
                    <field name="comment" text="$5"/>
                </bom>
                <adduser group="MyChangers" user="${NOTIFICATION_GROUP}"/>
                <setenv name="Changes" value="$4 - $1&lt;br/&gt;" type="temp append"/>
            </match>
        </resultsblock>
     </command>