<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Alex Amiryan's Linux Blog &#187; cvs</title>
	<atom:link href="http://www.amiryan.org/tag/cvs/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.amiryan.org</link>
	<description>Just sharing my experiance in linux</description>
	<lastBuildDate>Tue, 10 Nov 2009 19:56:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>Efficient usage of CVS in web development</title>
		<link>http://www.amiryan.org/2008/08/01/efficient-usage-of-cvs-in-web-development/</link>
		<comments>http://www.amiryan.org/2008/08/01/efficient-usage-of-cvs-in-web-development/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 12:11:52 +0000</pubDate>
		<dc:creator>Alex Amiryan</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[howtos]]></category>
		<category><![CDATA[cvs]]></category>

		<guid isPermaLink="false">http://alexamiryan.wordpress.com/?p=101</guid>
		<description><![CDATA[Hello. In this post I am going to introduce how we started using CVS in our work. First of all I want to tell what our job is. We are developing several big websites with about 20 000 lines of source code. We have 4 dedicated servers with Linux OS. So we need good version [...]]]></description>
			<content:encoded><![CDATA[<!--Amazon_CLS_IM_START--><p>Hello. In this post I am going to introduce how we started using CVS in our work.</p>
<p>First of all I want to tell what our job is. We are developing several big websites with about 20 000 lines of source code. We have 4 dedicated servers with Linux OS. So we need good version control system and ability to make changes to website several times a day. Also it will be good not upload files to server by hand and to have some test place to test unstable code. So I have chosen CVS for this purpose. But the problem is that CVS mostly for application developers who make new releases once a month. So we have to think some scheme of work to deal with CVS in web development.</p>
<p>Here is my solution to this problem. Note that we are working with this scheme for more than month and it seems to fit all our requirements.</p>
<p>So every developer has its own work directory which is located on the development server. Let&#8217;s put them in <strong>/home</strong>. So for example developer Mike has <strong>/home/mike</strong> and if he developing project which called <strong>mysite</strong> then it will be located on <strong>/home/mike/mysite</strong>.</p>
<p>Development server has to have apache and bind configured to allow developers to work and test their work. Every project has to have its own first level domain on developer server. Every user has to have it&#8217;s own subdomain on every project. So we have domain <strong>http://mysite</strong> and Mike can access his copy of <strong>mysite</strong> at <strong>http://mike.mysite</strong> . Also we need special domain for testing joined stable version of the site. Let&#8217;s call it <strong>http://test</strong> and we can access current stable version of mysite at <strong>http://mysite.test</strong> . This files can be located in <strong>/home/test</strong> .</p>
<p>Our online server has to have 2 CVS copies of the site and one clean copy (without CVS folders) which will serve online site. Let&#8217;s put CVS copies in <strong>/home/mysite_test</strong> and <strong>/home/mysite_dev</strong>. Online site will be in <strong>/home/mysite</strong>. If online site&#8217;s address is <strong>http://www.mysite.com</strong> then we have to also have <strong>http://dev.mysite.com</strong> and <strong>http://test.mysite.com</strong> .</p>
<p style="text-align:center;"><strong>Start of a project</strong></p>
<p>Project manager creates new CVS repository and new module. Let&#8217;s call it <strong>mysite</strong>. Then he tags whole project with tag which called <strong>mysite-stable-current</strong>.</p>
<pre class="brush: bash">cvs -q rtag -F -r HEAD mysite-stable-current mysite</pre>
<p style="text-align:center;"><strong>Start making new job on project</strong></p>
<p>When developper with name is <strong>Mike</strong> want to start making new job on the project he creates a new branch with name <strong>mysite-mike-job1</strong> from tag <strong>mysite-current-stable</strong> and starts to work on it.</p>
<pre class="brush: bash">cvs -q rtag -B -b -F -r mysite-stable-current mysite-mike-job1 mysite</pre>
<p style="text-align:center;"><strong>While developing</strong></p>
<p>While developing developer may want to test his work on online server, but without joining it to main branch. In that case he have to commit his current files and execute following command from server in <strong>/home/mysite_dev</strong>.</p>
<pre class="brush: bash">cvs -q update -d -r mysite-mike-job1</pre>
<p>Then he can test his unstable code on <strong>http://dev.mysite.com</strong></p>
<p style="text-align:center;"><strong>When job is finished</strong></p>
<p>When developer finishes and tested his job he needs commit all his files. After that project manager have to join the changes of the developer to the main branch. So he executes following commands:</p>
<pre class="brush: bash">mkdir /tmp/jkh23bhlh234
cd /tmp/jkh23bhlh234
cvs -q checkout -r mysite-mike-job1 mysite
cd mysite
cvs -q update -d -j mysite-stable-current
cvs -q commit -m "Updated with latest stable"
cd /home/manager/mysite
cvs -q update -d -j mysite-mike-job1
cvs -q commit -m "joined mysite-mike-job1"</pre>
<p>Then we have to tag this branch as merged</p>
<pre class="brush: bash">cvs -q rtag -F -r mysite-mike-job1 mysite-mike-job1-merged mysite</pre>
<p>To have history of stable versions we have to make additional tag in format <strong>mysite-stable-YEAR-MONTH-DAY_HOUR-MINUTE-SECOND</strong></p>
<pre class="brush: bash">cvs -q rtag -r HEAD mysite-stable-108-7-1_6-40-21 mysite</pre>
<p>Then we tag our joined version as <strong>mysite-stable-current</strong></p>
<pre class="brush: bash">cvs -q rtag -F -r HEAD mysite-stable-current mysite</pre>
<p style="text-align:center;"><strong>Uploading to online server</strong></p>
<p>To upload last stable version to server we need to execute following command in online server&#8217;s <strong>/home/mysite_test</strong> directory</p>
<pre class="brush: bash">cvs -q update -d -r mysite-stable-current</pre>
<p>Then we can make final test of the site on <strong>http://test.mysite.com</strong> before putting it online. When we finished testing and code is ready to become online we just need to execute following command to copy site from test to online:</p>
<pre class="brush: bash">/bin/cp -aT /home/mysite_test /home/mysite
find /home/mysite -name CVS -prune -exec rm -rf {} \\;
find /home/mysite -name .cvsignore -prune -exec rm -rf {} \\;</pre>
<p>That&#8217;s all.</p>
<p>I have wrote bunch of scripts in Perl to automate the process I have recently described. This project is called <a href="http://github.com/alexamiryan/Web-CVS-Tools">Web-CVS-Tools</a>. You just need suexec to execute these scripts with privileges of the right user according to your system configuration.</p>
<p>You can download latest version of <a href="http://github.com/alexamiryan/Web-CVS-Tools">Web-CVS-Tools</a> from <a href="http://github.com/alexamiryan/Web-CVS-Tools/tarball/master">here</a></p>
<p>Let me explain the purpose of each file in the <a href="http://github.com/alexamiryan/Web-CVS-Tools">Web-CVS-Tools</a>. Let&#8217;s start from dev_server directory</p>
<p><strong>work_config_global.pl</strong> &#8211; Global configuration for developers work script. There is defined list of the project and list of the developers.<br />
<strong>work.pl</strong> &#8211; Main script for developers. It must NOT be called directly, it must be included by the dev_username/work.pl scripts.<br />
<strong>dev_username/config.pl</strong> &#8211; Configuration for each developer.<br />
<strong>dev_username</strong><strong>/work.pl</strong> &#8211; Script that developer should call to get his work interface.<br />
<strong>manager/merge.pl</strong> &#8211; Script for project manager to merge developer&#8217;s work to main branch.</p>
<p>Now let&#8217;s look on online_server directory</p>
<p><strong>update_config.pl</strong> &#8211; Configuration for online server. There is array of sites where you must specify the directories of the dev, test main sites. Also there is array of developers and of course address of the CVSROOT.<br />
<strong>update.pl</strong> &#8211; Main script for uploading last stable version. Must be called directly.</p>
<p>That&#8217;s all.</p>
<p>If you have any questions, please do not hesitate to write me <img src='http://www.amiryan.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>For learning CVS I will advice to buy this book: </p>
<!--Amazon_CLS_IM_END-->]]></content:encoded>
			<wfw:commentRss>http://www.amiryan.org/2008/08/01/efficient-usage-of-cvs-in-web-development/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
