Quick reference -CVS

All information in this is based on the documentation (http://cvsgui.sourceforge.net/howto/cvsdoc/cvs_5.html#SEC61) and my practical experience

Create a branch and add a file into a branch
Step1: Checkout the path of code for which you want 2 make a branch into a new sandbox
Step2: Branch created with all files present in the directory.
       $cvs tag -b BRANCH_NAME_YOU_LIKE_TO_GIVE
Step3: To verify the creation either checkout the branch or update the path with the branch details
       $cvs co -d DIR_NAME -r BRANCH_NAME_YOU_LIKE_TO_GIVE CVS_PATH_OF_THE_MODULE_YOU_WANT_TO_CHECK_OUT
or go into the path where your code resides and run the below comand to update all files in that path with this branch
       $cvs upd -r BRANCH_NAME_YOU_LIKE_TO_GIVE

Step3: Adding single file to the newly created branch
       $cvs tag -b BRANCH_NAME_YOU_LIKE_TO_GIVE your_perl_file.pl

Merge Changes from Branch to Trunk

  Consider this revision tree:

    +—–+    +—–+    +—–+    +—–+
    ! 1.1 !—-! 1.2 !—-! 1.3 !—-! 1.4 !      <- The main trunk
    +—–+    +—–+    +—–+    +—–+
                    !
                    !
                    !   +———+    +———+
        Branch R1fix -> +—! 1.2.2.1 !—-! 1.2.2.2 !
                        +———+    +———+
The branch 1.2.2 has been given the tag (symbolic name) `R1fix’. The following example assumes that the module `mod’ contains only one file, `m.c’.

  $cvs checkout mod               # Retrieve the latest revision, 1.4

  $cvs update -j R1fix m.c        # Merge all changes made on the branch,
                                 # i.e. the changes between revision 1.2
                                 # and 1.2.2.2, into your working copy
                                 # of the file.

  $cvs commit -m “Included R1fix” # Create revision 1.5.
A conflict can result from a merge operation. If that happens, you should resolve it before committing the new revision.
            OR

The checkout command also supports the `-j branch’ flag. The same effect as above could be achieved with this:
    $cvs checkout -j R1fix mod
    $cvs commit -m “Included R1fix”

Creating Tags
$cvs co -d dirname Module
$cvs tag Tagname
This will hep you to create a snapshot of the current updated code in CVS. This is very helful we want to restore the code to this point at some time even if we have done enough coding on the HEAD.

Command to Update the code base with HEAD and BRANCH code.
# Update the sandbox with trunk
$cvs upd -A
# Update the sandbox with a branch
$cvs upd -r BRANCH_NAME

Quick Reference- Perl one liners

#search for a pattern in a file just like Linux grep command
$perl -ne ‘print if /findword/;’

#search and replace a pattern in a file and print the modified contents on the screen
$perl -pe ‘s/findword/replaceword/g;’

#search and replace a pattern in a file. Original files are backed up in .bak extension. This is one of the most powerful command if you want to do operations on large set of files in a directory.
$perl -pi.bak -e ‘s/findword/replaceword/’

#see the encode and decode characters of URLs
$perl -MURI::Escape -le ‘$var=qq(userid,;); print uri_escape($var);’
$perl -MURI::Escape -le ‘$var=qq(userid%2C%3B); print uri_unescape($var);’