Saturday, July 26, 2014

Common commands for stupid CVS system

I have to say CVS is an outdated source code management tools; but since there are still some big and long-history companies are using it, here are a few commonly used commands usage we can quick refer to.

login/logout


  • export CVSROOT=:pserver:username@cvsserver.com:/repos
  • cvs login
  • cvs logout
This is the first step before any CVS command can be called.

Checkout

  • cvs checkout products/module
    • Checkout source code in local directory, products/module
  • cvs checkout -d module products/module
    • Checkout source code in current directory ,module

Export

Export is something like a Checkout command except there is not CVS folder, so you cannot update codes then.
  • cvs export -D now products/module
  • cvs export -D <datevalue> products/module
  • cvs export -r tag products/module

Update

  • cvs update
    • update current folder, include sub-folder
  • cvs update file_name
    • update a single fole
  • cvs update -C file_name
    • discard local modification
  • cvs update -p -r1.2 file_name >file_name
    • update to an old version, for example 1.2

Add

  • cvs add new_file
    • add a file, a 'cvs commit' command is required later
  • How to add a folder recursive
    • cd fold_to_be_added
      • enter to the folder to be added
    • cvs import -m "Add a folder" products/module/fold_to_be_added INITIAL start
      • products/module/fold_to_be_added is the destination CVS path to be added.

Delete

  • cvs rm file_name
    • a 'cvs commit' command is required later.
  • How to delete a folder
    • stupid CVS cannot let you delete a foler
  • How to delete files recursively
    • find . -type f ! -path \*CVS\* -exec rm {} \; -exec cvs remove {} \;
    • Notice: folder and subfolder will not be deleted, only files are deleted.

Rename

  • There is no solution to remove a file, but you can remove and add again
    • mv oldfile newfile
    • cvs remove oldfile
    • cvs add newfile
    • cvs commit -m "renamed old to new" oldfile newfile
  • Notice: you cannot renmame a foler, because a folder cannot be deleted.

Commit

  • cvs commit -m "write some comments here" file_name1 file_name2 ...

Check

  • cvs diff -r1.3 -r1.5 file_name
    • diff 2 versions
  • cvs diff file_name
    • diff local changes
  • cvs status file_name
  • cvs history -c -a -D 2013-01-01 -p products/module
  • cvs history -c -u username -D 2013-01-01 -p products/module

Tag

  • cvs tag tagname products/module
    • add tag
  • cvs rtag tagname products/module
    • add tag remotely, i.e,. don't need download a source code.
  • cvs tag -d tagname products/module
    • remove a tag
  • cvs rtag -d tagname products/module
    • remove a tag removely

Branch

  • Create a branch
    • cvs checkout -d module.branch products/module
      • Checkout a copy source code from trunk
    • cd module.branch
    • cvs tag -b branch_name
  • Checkout branch
    • cvs checkout -d module.branch -r branch_name products/module

Patch

  • Create a patch from source
    • cvs diff > module.diff
  • Apply patch
    • patch -p0 <path_to_patch/module.diff
    • patch -p1 -d module.branch <path_to_patch/module.diff