Tuesday, March 18, 2008

Links and Materials

http://www.gnulamp.com/cvsdiff.html

The diff Command

The diff command shows the difference between two revisions of a file. If you invoke this command without any options, CVS shows the difference between the current local working file and the earlier revision stored in the repository. The current local working file need not be saved in the repository using the commit command. For example, to show a difference between the new.txt file, which is saved in the repository yesterday, and the local working copy of the same file, the syntax is:
$ cvs diff –D yesterday new.txt new.txt

various options that you can use with the diff command to display differences according to your requirement:
Options of the diff Command
Option Description
-lines Displays lines of context.
-a Treats files as text to compare files line-by-line.
-b Ignores white spaces.
-B Ignores changes, such as insertion and deletion of blank lines.
-binary Reads and writes data in binary format.
-brief Displays information whether the files differ.
-c Uses the content output format.
-d Changes the algorithm to find minor differences.
-expand-tabs Expands tabs to tableserve the alignment of tabs in the input files.
-H Handles large files with numerous scattered changes.
-I Ignores changes in the case.
-I Ignore changes, such as insertion or deletion of lines.
-L Uses label instead of the context format and unified format headers.
-s Displays a report when the two files are same.
-u Uses the unified output format.
-w Ignores white spaces when comparing files.
-y Uses the side-by-side output format.

The checkout Command

The checkout command creates or updates the current working directory with copies of source files from the repository. You need to specify the module in the repository from which you require files. Depending on the file structure in that module, files will be copied to recursively created directories, which is similar to creating a mirror image of the module. The following syntax uses the checkout command:
$ cvs checkout new_module

By default, all files created have read-write attributes. To change the file attributes, you need to specify the –r command option. The top-level mirror directory is created in the directory where checkout command is invoked and has the same name as the mirrored module. Table B-1 lists the various options that you can use with the checkout command:

Options of the checkout Command
Option Description
-D Uses the most recent revision of a file.
-f Retrieves the most recent revision, if no matching revision is found.
-k Processes keywords according to kflag.
-l Locates a file in the current working directory.
-n Disables the checkout command.
-P Deletes empty directories from the repository.
-p Retrieves files for the standard output.
-R Checks out directory recursively.
-r Implements the revision tag.
-A Resets sticky tags, dates, and –k options.
-c Copies module files.
-d Creates a working directory.

The rtag Command

The rtag command specifies a tag name to a module in the repository. This command does not require a local working copy. This command should be used carefully because it directly affects the repository. A tag name created using rtag can be deleted using the –d command option. For example, to create a new tag, New_tag, in the repository module, my_project, for the revision dated no later than yesterday, the syntax is:
$ cvs rtag –D yesterday New_tag my_project

The rdiff Command

The rdiff command shows the difference between two releases of the same project in the repository. For example, use the following syntax to display the difference between two releases, release1 and release2:
$ cvs rdiff -R release1 release2
various options that you can use with the rdiff command:
Option Description
-f Retrieves the most recent version.
-c Uses the context diff format.
-s Generates a summary change report.
-t Displays a diff of the top two revisions.
-u Uses the unidiff format.

The edit Command

The edit command enables you to edit or modify a file. When you edit a file, the file is temporarily added to the list of file watchers. You can release the file from the list of file watchers using the unedit command. For example, to edit a watched file in the current local working directory, use the following syntax:
$ cvs edit –l watched_file.txt

To release a watched file from the list of file watchers, use the following syntax:
$ cvs unedit –l watched_file.txt

The remove Command

The remove command removes files and directories from a CVS repository. Before removing a file, you need to delete files from the current working copy of the repository. Use the remove and commit commands, respectively, to delete the files from the repository. For example, to use the remove command, the syntax is:
$ rm new.txt
$ cvs remove new.txt
$ cvs commit –m "Removed file" new.txt
Note
You need to explicitly state the file name in all the commands. CVS does not need a method to remove directories. To delete a directory, first delete all the files from working copy of the directory. Use the remove command to delete all the files from CVS and commit the changes. Change the current directory to one level above and run the update command with the –P option, which removes the empty directory.For example, to use the remove and the commit commands, use the following syntax:
$ rm new1.txt
$ rm new2.txt
$ cvs remove new1.txt new2.txt
$ cvs commit –m "Removed files" new1.txt new2.txt
$ cd.
$ cvs update –P

The add Command

The add command adds files and directories to the CVS repository. To add a file to the repository, you need to use the commit command. For example, to add the new.txt file to the CVS repository, use the following syntax:
$ cvs add new.txt$ cvs commit –m "New text file" new.txt
Note
To add a directory, create the directory using mkdir. Use the add command to add the directory. A CVS subdirectory is automatically created within every directory added to a repository.
To add a binary file, you need to use the –kb command option. For example, to add a binary file, new.gif, the code is:
$ cvs add –kb new.gif
$ cvs commit –m "New binary file" new.gif

The commit Command

The commit command saves the changes of the current working files into the repository. When you save a file in your working directory, it does not affect the repository. Source files in the repository are independent of your local files. With commit, you can save changes made to a local file into the repository, where the file is saved as a later revision of the original source file. For example, to save the original and changed files with revision numbers, such as 1.1 and 1.2, the syntax is:
$ cvs commit –m "New text file" new.txt
various options that you can use with the Commit command:
Options Description
-l Retrieves files from the current working directory.
-R Commits directories recursively.
-r Commits revision.
-F Retrieves log messages from files.

The init Command

The init command creates a new CVS repository. You should use the –d global option to specify the absolute path of the repository. This ensures that the existing repositories are not affected by this command. For example, to create a new repository, new_repository, at a specified location, the command is:

$ cvs –d /usr/local/new_repository init

The update Command

The update command synchronizes the changes in the repository source files with the files in the current working copy. This is useful when multiple end users are working on the same set of files. End users commit changes after you invoke checkout. This enables you to incorporate most recent revisions in the local working copy of the repository. For example, to update all the files in my_project except new.txt, the syntax is:

$ cvs update –I new.txt –P my_project

various options that you can use with the update command:
Option Description

-A Resets tags, dates, and keyword options.
-C Overwrites locally modified working files with original files from the repository. This is particularly useful if local files are corrupted.
-d Replicates the directory structure of the repository, if it is not already mirrored in the local working copy. This is useful if a directory has been created after you checkout.
-I Ignores the specified file.
-w Filters the specified file. You can use wildcard patterns to filter files.
-j Merges changes from the first specified revision to the second specified revision of the same file in the current working directory.

The Log Command

The log command displays log messages for files. Log messages are specified using the editor invoked after commit or using the –m command option. This command displays all the revisions made to a file, including revision number, author, Greenwich Mean Time (GMT) timestamp, number of lines changed, and date on which the changes were made. Every log message associated with a revision is also displayed.

For example, to view the log message for my_project, the syntax is:

$ cvs log –l my_project

Note

The –l option generates logs only for the my_project directory, instead of doing it recursively, which is the default behavior.

various options that you can use with the log command:
Option Description
-b Prints information about revisions on the default branch.
-d Prints information about revisions with a checkin date and time.
-h Prints names of the Revision Control System (RCS) file, the file in the working directory, head, branch, locks, symbolic names, access lists, and suffixes.
-R Prints only the name of the RCS file.

The export Command

The export command enables you to export files from the main CVS repository to another directory, which is not controlled by CVS. This is useful when you want to release a software version or halt a project at a given stage.

For example, to export the CVS project, my_project, to a new directory, where the revision date of the files is not later than yesterday, the syntax is:

$ cvs export –D yesterday –d /usr/local/new my_project

lists the various options that you can use with the export command:

Option Description
-f Retrieves the most recent revision of a file.
-n Disables the checkout program.
-R Exports directories recursively.
-d Creates the working directory.

The history Command

The history command displays information about files and end users. CVS maintains a history file, where it logs the use of commands, such as checkout, commit, release, rtag, and update. These commands display the information stored in the history file.The history command cannot function without options. It also requires partial file names in the form of substrings, instead of complete file names. It matches all file names containing the given substring and displays information pertaining to them. For example, to view the data pertaining to the my_project module, the syntax is:
$ cvs history –m my_project
various options that you can use with the history command:
Option Description

-c Reports when each times the commit command are used.
-e Displays all record types.
-m Displays report of a specific module.
-o Displays report of checked-out modules.
-T Displays report on all tags.
-l Displays data pertaining to the most recent event in a project.
-n Displays data pertaining to the most recent event. This is different from events happening within a module. For example, if a file is updated within a module, the file is affected.
-p Displays data pertaining to a given directory within a repository.

The import Command

The import command enables you to incorporate source files from another project into your repository. This project can be either entirely new or a branch of an already existing module. There are three arguments with the import command:

Name of the repository and the module, if any
The vendor tag
The release tag

You need to specify the name for the module where the files will be stored in your repository. If a specified directory does not exist, CVS creates the directory and stores the files. For example, to import files in the newcvs repository with a vendor tag, Newuser, and a release tag, Version1, the syntax is:

$ cvs import –m "Import files" newcvs Newuser Version1

If CVS ignores a file and does not import the file, CVS shows I along with the file name. For example, if a file, old.txt, is being ignored and not imported, CVS shows:

-I old.txt

Note You should use import when multiple files are added into the repository. To add a single file, use the add command.

When you import files in the main repository, the current working directory is not affected. To use the newly imported files, you need to explicitly checkout them into your current working directory.various options that you can use with the import command:


Option Description

-m Uses messages as log information.
-k Specifies the desired keyword expansion mode.
-I Specifies the file names to be ignored, while importing.
-W Specifies the file names to be filtered, while importing.

The editors Command

The editors command shows a list of end users editing a watched file. For example, to view a list of end users making changes to the watched file, new.txt, the syntax is: $ cvs editors –l new.txt

The watchers Command

The watchers command shows the list of watchers for the specified files. For example, the following command displays a list of watchers for the local working copy of a watched file, new.txt: $ cvs watchers –l new.txt

Monday, March 17, 2008

The watch Command

The watch command specifies a watch on files. This command is used when you want to view the changes made to a file. To use this command, you need to use the following subcommands:

on: Indicates that a file is being watched. Watched files are created with read-only attributes on checkout. You need to use the edit command to make changes to the file.

off: Indicates that a file is no longer being watched.

add: Adds files to the list of file watchers. The changes made to the file are known when a change is made using the edit or unedit commands.

remove: Removes files from the list of file watchers. You are not informed about changes are made to the file. For example, the following command sets a watch on the new.txt file:

$ cvs watch on new.txt

The status Command

The status command shows the status of the current local working files. When used with the –v command option, it shows the tag associated with each file. This is an informational command that does not alter the files in any way. For example, to view the status of the new.txt file, the syntax is: $ cvs status –l new.txt

The tag Command

The tag command enables you to specify a tag name to a revision made to a file or a project. A tag bookmarks the state of a project at the time it was assigned to the project. When used with the –b command option, it creates branches in the repository.

For example, to create a new branch with the new_branch tag in the repository module, my_project, the syntax is:

$ cvs tag –b new_branch my_project

You can delete a tag using the –d command option. Using the –c command option, you can check if a current working file has changed, but a commit has not been invoked. CVS exits with an error and tags are not created.

The annotate Command

The annotate command displays the revision number, time, and the name of end users modifying the files. Every line displayed corresponds to a single revised line. This command does not alter the files in the repository. For example, to view the information of the new.txt file, the syntax is:
$ cvs annotate –l new.txt

The logout Command

The logout command enables you to logout of the repository by removing the password stored in the .cvpass file. You should invoke this command without any options. For example, you can use the following syntax: $ cvs logout

The login Command

The login command confirms a password for a particular repository. This is used in a client-server environment. The password information is stored in your local .cvpass file. As a result, authentication is required only once per session. If the password is changed on the server, you need to logon again. For example, you can use the following code:

$ cvs – d :pserver:user:repositorypath login password

Note If you do not give the password, CVS automatically prompts for the password at the command line.

The release Command

The release command releases or cancels the checkout command. This indicates that a local working copy is no longer in use. A release is logged in the CVS history file. This command is never invoked from the local working copy. It has to be invoked from a directory one level above it. You can specify an absolute path to the CVS repository using the –d global option. Using the –d option, you can delete the local working copy including new directories created in it. Using the release command, you can specify that the files will not be used. You can also check if there are any uncommitted changes and decide whether to add the file to the repository.

For example, the following code invokes the release command from the parent directory:
$ cd
$ cvs –d /usr/local/my_repository release –d my_project

In the above code, you need to specify an absolute path to the repository because CVS does not reside in the parent directory. The my_project directory is released from my_repository and deleted along with the subdirectories it contains.

The release Command

The release command releases or cancels the checkout command. This indicates that a local working copy is no longer in use. A release is logged in the CVS history file. This command is never invoked from the local working copy. It has to be invoked from a directory one level above it. You can specify an absolute path to the CVS repository using the –d global option. Using the –d option, you can delete the local working copy including new directories created in it. Using the release command, you can specify that the files will not be used. You can also check if there are any uncommitted changes and decide whether to add the file to the repository.For example, the following code invokes the release command from the parent directory:

$ cd

$ cvs –d /usr/local/my_repository release –d my_project

In the above code, you need to specify an absolute path to the repository because CVS does not reside in the parent directory. The my_project directory is released from my_repository and deleted along with the subdirectories it contains.

The export Command

The export command enables you to export files from the main CVS repository to another directory, which is not controlled by CVS. This is useful when you want to release a software version or halt a project at a given stage.

For example, to export the CVS project, my_project, to a new directory, where the revision date of the files is not later than yesterday, the syntax is:

$ cvs export –D yesterday –d /usr/local/new my_project

lists the various options that you can use with the export command:

Option Description

-f Retrieves the most recent revision of a file.

-n Disables the checkout program.

-R Exports directories recursively.

-d Creates the working directory.

SUMMARY: Syntax of the CVS command

Usage: cvs [cvs-options] command [command-options] [files...]        
Where 'cvs-options' are:
-H Displays Usage information formmand
-Q Cause CVS to be really quiet.
-q Cause CVS to be somewhat quiet.
-r Make checked-out files read-only
-w Make checked-out files read-write (default)
-l Turn History logging off
-n Do not execute anything that will change the disk
-t Show trace of program execution -- Try with -n
-v CVS version and copyright
-b bindir Find RCS programs in 'bindir'
-e editor Use 'editor' for editing log information
-d CVS_root Overrides $CVSROOT as the root of the CVS tree
and where 'command' is:
add Adds a new file/directory to the repository
admin Administration front end for rcs
checkout Checkout sources for editing
commit Checks files into the repository
diff Runs diffs between revisions
history Shows status of files and users
import Import sources into CVS, using vendor branches
export Export sources from CVS, similar to checkout
log Prints out 'rlog' information for files
rdiff 'patch' format diffs between releases
release Indicate that a Module is no longer in use
remove Removes an entry from the repository
status Status info on the revisions
tag Add a symbolic tag to checked out version of RCS file
rtag Add a symbolic tag to the RCS file
update Brings work tree in sync with repository

FREQUENTLY USED CVS COMMANDS

  • cvs add [ filename ]: Adds a new file/directory to the repository
  • cvs admin filename: Administration front end for rcs
  • cvs checkout filename: Checkout sources for editing
  • cvs commit [ filename ]: Checks files into the repository
  • cvs diff filename: Runs diffs between revisions
  • cvs history [ filename ]: Shows status of files and users
  • cvs status [ filename ]: Status info on the revisions
  • cvs release [ filename ]: Status info on the revisions
  • cvs update [ filename ]: Brings work tree in sync with repository

Tagging Files in CVS

Follow Link...
http://www.idevelopment.info/data/Programming/change_management/unix_cvs/PROGRAMMING_CVS_Commands.shtml#Tagging%20Files%20in%20CVS

Checking Out Files from CVS


Checking Out Files from CVS

To checkout a project / module:
cvs co <project / module name>

In the following example, I will checkout ProjectX:
% cvs co ProjectX  cvs checkout: Updating ProjectX  
U ProjectX/File1.java
U ProjectX/File2.java
U ProjectX/File3.java
cvs checkout: Updating ProjectX/new_stuff
U ProjectX/new_stuff/a.txt
U ProjectX/new_stuff/b.txt
U ProjectX/new_stuff/c.txt

You can also checkout individual files without including their directory structure. For example, I want to checkout the files a.txt, b.txt, and c.txt but without any of the directory structure. I want the files checked out to the current directory I am in:
% cvs co -d . ProjectX/new_stuff  
cvs checkout: Updating .
U a.txt
U b.txt
U c.txt

Or I can include a directory name to checkout to. For example, I want to checkout the same files into a directory named working:
% cvs co -d working ProjectX/new_stuff  
cvs checkout: Updating working
U working/a.txt
U working/b.txt
U working/c.txt

Adding Files to CVS


Adding Files to CVS

To add a file(s) to CVS:
cvs add <file name(s)>

In the following example, I will use the directory I created above (new_stuff) and create several files within that directory:
% cd new_stuff  
% touch a.txt
% touch b.txt
% touch c.txt
% cvs add *.txt
cvs add: scheduling file `a.txt' for addition
cvs add: scheduling file `b.txt' for addition
cvs add: scheduling file `c.txt' for addition
cvs add: use 'cvs commit' to add these files permanently
% cvs commit -m "Added new files"
cvs commit: Examining .
RCS file: /var/lib/cvsrepos/ProjectX/new_stuff/a.txt,v done
Checking in a.txt; /var/lib/cvsrepos/ProjectX/new_stuff/a.txt,v <-- a.txt
initial revision: 1.1
done
RCS file: /var/lib/cvsrepos/ProjectX/new_stuff/b.txt,v
done
Checking in b.txt;
/var/lib/cvsrepos/ProjectX/new_stuff/b.txt,v <-- b.txt
initial revision: 1.1
done
RCS file: /var/lib/cvsrepos/ProjectX/new_stuff/c.txt,v
done
Checking in c.txt; /var/lib/cvsrepos/ProjectX/new_stuff/c.txt,v <-- c.txt initial revision: 1.1
done


Adding Directories to CVS


Adding Directories to CVS

To add a directory:
cvs add <directory name>

In the following example, I created a directory called new_stuff:
% cd ProjectX  % mkdir new_stuff  % cvs add new_stuff  Directory /var/lib/cvsrepos/ProjectX/new_stuff added to the repository

Viewing Changes / Updates To Your Sandbow But Without Actually Making Any Changes in Unix


Viewing Changes / Updates To Your Sandbow But Without Actually Making Any Changes

You will need to use the -nq argument.

For example, if there were no changes made by you (or by others that have committed changes to the repository), you would simply get your prompt back:

% cvs -nq update  %

If there were changes, however, then you would see those changes that CVS would want to apply. Those changes, however, will not be made to your sandbox.
% cvs -nq update  U TestCvsWS/TestCvsPRJ/src/info/idevelopment/PrintName.java  %

Exporting Modules from CVS in CVS


Exporting Modules from CVS

The syntax is:
cvs export -r tag module

For example, to export from the HEAD of the ProjectX module:
% cvs export -r HEAD ProjectX

Removing Projects from CVS in Unix


Removing Projects from CVS

Removing a project (or other directory structure) from CVS can be done by logging into the CVS repository.
% cd /var/lib/cvsroot    
% ls -l
total 4
drwxrwsr-x 3 cvs cvsdev 1024 Jan 23 19:30 CVSROOT/
drwxrwsr-x 2 oracle cvsdev 512 Jan 24 19:38 ProjectX/
% rm -rf ProjectX

Importing Projects into CVS in Unix


Importing Projects into CVS


% cd /tmp  % mkdir ProjectX  
% touch ProjectX/File1.java
% touch ProjectX/File2.java
% touch ProjectX/File3.java
% cd ProjectX
% cvs import ProjectX INITIAL start

Ensure that you now backup and remove the original ProjectX working directory and checkout the newly imported module when you need to work on it:
% rm -rf ProjectX  
% cvs co ProjectX U ProjectX/File1.java U ProjectX/File2.java U ProjectX/File3.java

Logging into a CVS Repository in Unix


Logging into a CVS Repository in Unix

Local Repository
With a local CVS Repository, you simply need to set your CVSROOT environment variable to the location of the CVS Repository as in the following example:
% CVSROOT=/var/lib/cvsroot
% export CVSROOT


Remote Repository

% CVSROOT=:pserver:<username>@<computername>:<repository>

Login to a remote CVS repository using the :pserver: protocol. The CVS server is named alex and my user name is oracle. Keep in mind that I needed to first create the local user, oracle, on the CVS host. (Which, again, in this example is named alex.)
% CVSROOT=:pserver:oracle@alex:/var/lib/cvsroot  
% cvs login Logging in to :pserver:oracle@alex:/var/lib/cvsroot CVS password: *******


Creating a CVS Repository in Unix


Creating a CVS Repository in Unix

The following set of commands will create a CVS repository in the directory /var/lib/cvsroot:
# mkdir /var/lib/cvsroot  
# chgrp cvsdev /var/lib/cvsroot
# chmod g+srwx /var/lib/cvsroot
# cvs -d /var/lib/cvsroot init
# chown -R cvs /var/lib/cvsroot
# ls -l /var/lib
total 2
drwxrwsr-x 3 cvs cvsdev 512 Jan 23 19:22 cvsroot
# ls -la /var/lib/cvsroot
total 6
drwxrwsr-x 3 root cvsdev 512 Jan 23 19:22 .
drwxr-xr-x 3 root other 512 Jan 23 19:18 ..
drwxrwsr-x 3 cvs cvsdev 1024 Jan 23 19:22 CVSROOT

Add Command

Add Command

Sunday, March 16, 2008

Checkout Command

Checkout Command

Thursday, March 13, 2008

CVS Command

CVS Command