Wednesday, January 12, 2011

Using Branch with WinCVS

How to setup a fix branch?


Step 1: Initial Situation: Let’s suppose
A. R-0-1-0 installed in production.
B. The current version of file1.txt is 1.3.
C. We have a production issue now. Meaning we have a bug in release R-0-1-0.

Step 2: Setup fix branch, F-0-1-0, for R-0-1-0 in CVS server.

A. Create -> Select the “Create a branch by module” menu item. -> In Create branch settings window, enter a tag/branch name “F-0-1-0” in the “New branch name” input field. Enter “CVSBranchTest” in the “Module to fork:” field. -> Under “Optionally use this revision/tag/date to create the branch”, check “Fork from this rev./tag” and enter “R-0-1-0”

B. Uncheck “Checkout read-only” option in Globals tab window.

C. Press the OK button

D. Verify the branch creatation: Within CVSBranchMain tree, right click on the file, file1.txt, and select “Graph select” option -> In Local setting window, click on OK button. -> Verify that “F-0-1-0” created as below:

Step 3: Selecting the Fix Branch to Work on:

To start working on a branch instead of the default development line, you have to bind your local copy to the branch. This is needed to make sure that actions such as updates, commits etc. work on the branch rather than on the main line of development.

To prepare your local copy to another branch, do the following:
A. Following Checkout Initial Release Module to checkout CVSBranchTest into CVSBranchF010 directory.
B. Verify F-0-1-0 checkout.
C. After working on file1.txt, right click on file1.txt file and select “Commit selection…” -> Enter the commit comment in the Commit settings window, and then click on OK button.

Step 4: Verify fixed version of the updated file: Right click on file1.txt stored in CVSBranchF010 directory -> Select “Graph selection…” -> Verify a version 1.2.2.1 is created under the F-0-1-0 branch.

Step 5: Repeating a few times for testing…

Step 6: Fix/Patch Release: Create new “R-0-1-1” tag for F-0-1-0 branch.
Create a tag by module… -> Enter the following info into Create tag settings window and then click on OK button.

Step 7: Verify Fix/Patch Release:
Right click on file1.txt stored under CVSBranchF010 folder à Select Graph select and click on OK button on the “Log settings” window.

How to merge fix branch into main?

When you are satisfied with the changes you have done on a branch, you may want those changes to be available on the main line of development. Incorporating changes from one branch to another, is known as merging. To merge from a branch, do the following:

Step 1: Right click on CVSBranchMain folder and select “Update selection…” option.

Step 2: Make sure “Create missing directories that exist in the repository” is checked.

Step 3: Select the Merge options tab -> Click the Only this rev./tag radio button -> In the Only this rev./tag input field, enter the tag/branch name,”R-0-1-1”. If you want to merge from a given timestamp in this tag, check the Date radio button and type in your preferred timestamp as well. -> Click on OK button.

Note: Any changes on the branch F-0-1-0 (or tag R-0-1-1) will now be merged into your local copy under CVSBranchMain folder.

How to merge fix branch into main?

When you are satisfied with the changes you have done on a branch, you may want those changes to be available on the main line of development. Incorporating changes from one branch to another, is known as merging. To merge from a branch, do the following:

Step 1: Right click on CVSBranchMain folder and select “Update selection…” option.
Step 2: Make sure “Create missing directories that exist in the repository” is checked.
Step 3: Select the Merge options tab -> Click the Only this rev./tag radio button -> In the Only this rev./tag input field, enter the tag/branch name,”R-0-1-1”. If you want to merge from a given timestamp in this tag, check the Date radio button and type in your preferred timestamp as well. -> Click on OK button.

Note: Any changes on the branch F-0-1-0 (or tag R-0-1-1) will now be merged into your local copy under CVSBranchMain folder.

How to resolve conflicts?

Once in a while, the CVS server will report a conflict when you update your files from the repository. A conflict occurs when two or more developers have changed the same few lines of a file. As CVS knows nothing of your project, it leaves resolving the conflicts to the developers. Whenever a conflict is reported, you should open the file in question, and search for lines starting with the string <<<<<<<. The conflicting area is marked like this:

<<<<<<< filename your changes ======= code merged from repository >>>>>>> revision
You should decide what the code should look like, do the necessary changes, remove the CVS markup, and commit your modifications to the repository.

If you would like a more graphical diff tool, there are several to go for. Download and install your preferred tool, then go to Admin -> Preferences / WinCvs menu item and check the External diff program checkbox, find your tool and click OK. Then, in the Diff -> Selection menu item, check the Use the external diff checkbox to use it.
cvs -z9 update -P -d -jR-0-1-1 (in directory C:\cygwin\home\hsual\alhsu\AlHome\CVSBranchMain\)
RCS file: /opt/cvs/CVSBranchTest/file1.txt,v
retrieving revision 1.2
retrieving revision 1.2.2.5
Merging differences between 1.2 and 1.2.2.5 into file1.txt
rcsmerge: warning: conflicts during merge

*****CVS exited normally with code 0*****

Step 5: Resolving Conflicts
Remove the lines in red below in file1.txt file: Suppose the lines in blue below are correct.
hsual@psgltpe014 $
hsual@psgltpe014 $ pwd
/home/hsual/alhsu/AlHome/CVSBranchMain
hsual@psgltpe014 $
hsual@psgltpe014 $ ls -a
./  .#file1.txt.1.8*  ../  CVS/  file1.txt*  file2.txt*  file3.txt*
hsual@psgltpe014 $
hsual@psgltpe014 $ more file1.txt
<<<<<<< file1.txt
file1 initial version.
Update this file for release R-0-1-0 (Release-Year-Month-Fix/Patch) changed for F-0-1-0 branch.
00.UPDATE 1.4
=======
file1 initial version.
Update this file for release R-0-1-0 (Release-Year-Month-Fix/Patch) changed for F-0-1-0 branch.
00. UPDATE 1.2.2.3
>>>>>>> 1.2.2.5
hsual@psgltpe014 $ edit file1.txt
hsual@psgltpe014 $ more file1.txt
file1 initial version.
Update this file for release R-0-1-0 (Release-Year-Month-Fix/Patch) changed for F-0-1-0 branch.
00. UPDATE 1.2.2.3
hsual@psgltpe014 $
After editing the file, do a Diff on file1.txt file: Right click on file1.txt file -> Diff selection… -> Select “Compare your local file with another revision/tag/branch/date:” option -> Enter “R-0-1-1” as below:
cvs -z9 diff -r R-0-1-1 file1.txt (in directory C:\cygwin\home\hsual\alhsu\AlHome\CVSBranchMain\)
 
*****CVS exited normally with code 0*****
Step 6: Right click on CVSBranchMain folder and select “Update selection…” option.

Step 7: Make sure “Create missing directories that exist in the repository” is checked.

Step 8: Select the Merge options tab -> Click the Only this rev./tag radio button -> In the Only this rev./tag input field, enter the tag/branch name,”R-0-1-1”. If you want to merge from a given timestamp in this tag, check the Date radio button and type in your preferred timestamp as well. -> Click on OK button.

Step 9: Commit update: Right click on CVSBranchMain à Select Commit selection… -> Enter comment -> click OK.

No comments: