The Open Source Swiss Army Knife

/unix/commandline/
/unix/commandline/ + sub-categories
http://www.sirfsup.com/
web directory content
    
      

Not logged in
Chat Register Login
return to:  http:/www.sirfsup.com      /unix   /commandline 
Permalink: comp-cvs.en.html
Title: add
article options : please login   |  print view    |  print view

CVS Quick Memo (Original By Suzuki in Japanese, this is translation version)

CVS Quick Memo

Original Japanese version (By Suzuki) is here.


  • Initialize

    Generating a cvsroot directory and its managing files. It is only once for each CVSROOT. Usually, you only need to do this once for your system.

         % cvs init      
         
  • Submit a directory structure. (The first add command.)
         % cvs import (position in the repository) vender-tag release-tag     
         Ex.: % cvs import project-1/foo susuki SNAP19980610
         
  • Add files
         % cvs add filename
         and
         % cvs commit
         

    Notice: You can only add files under your current directory.

  • Commit/update your change to repository.

    If you already add files to repository, just do cvs commit.

  • Delete files.
         % rm file-a
         % cvs remove file-a
         

    If you haven't rm file-a, cvs complains it.

  • Get the newest version
         % cvs checkout (the position of top directory in the repository)
         

    This makes a project under your current directory. And Using with the module function is more useful.

    Or, If you've already checkouted once,
         % cvs update
         
    makes update current directory recursively. But this is only effecting existing directory. If you want to update directory structure,
         % cvs update -Pd
         

    Each option means: P: Prune empty directories, d: Create any directories that exist in the repository if they're missing from the working directory.

  • Making snapshot with tags.
         % cvs tag tag-name     
         
    adds tags under current directory. If you want to get this by tag name, do next:
         % cvs checkout -r tag-name (the position of top directory in the repository)
         
  • Using $Id$

    If this string sequence is found in your file, CVS(Actually RCS) replace this with Id information. Use this in comments.

  • Making module

    This is useful! First, you should checkout the managing files of cvs via:

         % cvs checkout CVSROOT
         
    Now you get the directory CVSROOT under your current directory. Then you edit the modules in this directory. For example,
         knuthchap2 project/knuth/Vol1/taocp1/chap2
         
    After this, you can checkout chap2 with only next:
         % cvs checkout chap2
         
  • A notice of subcommands recursive ability.

    CVS manual said, ``Almost all'' of the subcommands of CVS work recursively when you specify a directory as an argument. Almost all means, for example, the add subcommand is not effect recursively.

  • Diff the files between in the current directory and in the repository

    You can get the difference between a current file and the file in the repository which is committed last time by:

         % cvs diff filename
         
  • Check the updating status
         % cvs status
         

    You can only know the your own change by cvs diff. If you want to know the others change, use this.

  • -n option

    Same as make's -n command. This do not change any files. You can check which files are changed without any change with:

         % cvs -n update
         

    Sometimes it is useful using status.

  • Conflicts

    When you've get a heavy conflict, your file becomes totally mess. The only solution is read the file. Before updating, you can check file status with cvs -n update. One the other way is that you return to one before version.

  • Making a branch

    You need to add tags to your file before making branch. It seems that, first making tags, and next branch information is added to the tags.

         % cvs rtag -b -r tag-name branch-name module-name
         

    The difference with tag is that you need only to specify the branch to get the newest revision of the branch.


    Appendix
    A. From RCS to CVS(By yamauchi@MPI)
    • From RCS to CVS (this information comes from CVS info file.): CVS uses RCS to manage each file revision information. Then, you can just move to files to the repository.
      • Imports files without RCS related files. Next is an example.
        1. Assume next files you have.
          	       % ls
          	       RCS  foo.C  bar.hh
          	       
        2. Move RCS related files to somewhere and import the files.
          	       % mv RCS ../RCS.bak	# move
          	       % cvs -d /repository/cvsroot import proj yamauchi snap1
          	       
        3. Remove RCS files created by cvs, and replace RCS's ,v files.
          	       % rm /repository/cvsroot/proj/foo.C,v
          	       % rm /repository/cvsroot/proj/bar.hh,v
          	       % cp ../RCS.bak/foo.C,v /repository/cvsroot/proj/
          	       % cp ../RCS.bak/bar.hh,v /repository/cvsroot/proj/
          	       
        4. Make sure to the revision information is OK with checking out. For the safety, you should keep original files to somewhere. In this example, revnum is just an adequate revision number. (here, 1.1)
          	       % mkdir tmp; cd tmp
          	       % cvs -d /repository/cvsroot checkout proj
          	       % cvs update -r[revnum] foo.C
          	       


    Leave a Reply
    Your Name:     anonymous
    Your Email:
    Website:  
    Comments:

    The author will be notified of your reply.
    return to top