<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Generating &#8220;Unified Diff&#8221; Files with ClearCase</title>
	<link>http://magnetiq.com/2007/09/07/generating-unified-diff-files-with-clearcase/</link>
	<description>Ates Goral's Personal Playground and Project Repository</description>
	<pubDate>Sun, 18 May 2008 11:25:57 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.2</generator>

	<item>
		<title>by: Keith Power</title>
		<link>http://magnetiq.com/2007/09/07/generating-unified-diff-files-with-clearcase/#comment-20810</link>
		<pubDate>Thu, 24 Jan 2008 14:32:07 +0000</pubDate>
		<guid>http://magnetiq.com/2007/09/07/generating-unified-diff-files-with-clearcase/#comment-20810</guid>
					<description>Thanks for this, it pointed me in the right direction. I was able to move all changes created in one branch over into another branch by scripting this and using diff and patch. I did it in 2 stages to keep an eye in everything.

NOTE: following scripts were run under cygwin on windows. In particular, they use pushd and popd, easily changed to work under *nix.
They assume DESTINATION variable set.

Stage 1, for each checked out file in source branch copy any non-existent files over to other branch, and check out any files that do exist:

&lt;pre class=&quot;code&quot;&gt;&lt;code&gt;for cofile in `cleartool lsco -cvi -r -s &amp;#124; sed s/\\\\/\\//g`
do
    if [ ! -e &quot;$DESTINATION/$cofile&quot; ]
    then
        echo &quot;File $cofile does not exist at destination, copying&quot;
	cp -r $cofile $DESTINATION/$cofile
	continue
    else	
        echo &quot;File $cofile exists at destination, checking out&quot;
	pushd &quot;$DESTINATION&quot;
	cleartool co -c &quot;Your comment&quot; $cofile
            chmod 666 $DESTINATION/$cofile
	popd
	continue
    fi
done
&lt;/code&gt;&lt;/pre&gt;

Stage 2, for each checked out file in source branch create diff between it and file in dest branch, then patch file in dest branch (new files will have empty patches applie. NOTE: you could easily diff against current ClearCase state using cleartool diff -pred -diff as in original article)

&lt;pre class=&quot;code&quot;&gt;&lt;code&gt;for cofile in `cleartool lsco -cvi -r -s &amp;#124; sed s/\\\\/\\//g`
do
    if [ ! -e &quot;$DESTINATION/$cofile&quot; ]
    then
        echo &quot;ERROR: File $cofile does not exist at destination&quot;
	continue
    else	
        echo &quot;File $cofile exists at destination, diffing and patching&quot;
        chmod 666 $DESTINATION/$cofile
	diff $DESTINATION/$cofile $cofile &amp;#124; patch $DESTINATION/$cofile
	continue
    fi
done
&lt;/code&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Thanks for this, it pointed me in the right direction. I was able to move all changes created in one branch over into another branch by scripting this and using diff and patch. I did it in 2 stages to keep an eye in everything.</p>
<p>NOTE: following scripts were run under cygwin on windows. In particular, they use pushd and popd, easily changed to work under *nix.<br />
They assume DESTINATION variable set.</p>
<p>Stage 1, for each checked out file in source branch copy any non-existent files over to other branch, and check out any files that do exist:</p>
<pre class="code"><code>for cofile in `cleartool lsco -cvi -r -s | sed s/\\/\//g`
do
    if [ ! -e "$DESTINATION/$cofile" ]
    then
        echo "File $cofile does not exist at destination, copying"
	cp -r $cofile $DESTINATION/$cofile
	continue
    else
        echo "File $cofile exists at destination, checking out"
	pushd "$DESTINATION"
	cleartool co -c "Your comment" $cofile
            chmod 666 $DESTINATION/$cofile
	popd
	continue
    fi
done
</code></pre>
<p>Stage 2, for each checked out file in source branch create diff between it and file in dest branch, then patch file in dest branch (new files will have empty patches applie. NOTE: you could easily diff against current ClearCase state using cleartool diff -pred -diff as in original article)</p>
<pre class="code"><code>for cofile in `cleartool lsco -cvi -r -s | sed s/\\/\//g`
do
    if [ ! -e "$DESTINATION/$cofile" ]
    then
        echo "ERROR: File $cofile does not exist at destination"
	continue
    else
        echo "File $cofile exists at destination, diffing and patching"
        chmod 666 $DESTINATION/$cofile
	diff $DESTINATION/$cofile $cofile | patch $DESTINATION/$cofile
	continue
    fi
done
</code></pre>
]]></content:encoded>
				</item>
</channel>
</rss>
