version-controlcommand-linecvs

How to acquire specific revision of a newly added file from CVS via command line?


One of our internally written tool is fed a cvs commit trace of the form:

Checking in src/com/package/AFile.java;
    /home/cvs/src/com/package/AFile.java,v <-- Afile.java
    new revision: 1.1.2.56; previous revision: 1.1.2.55
    done

The tool then acquires the file from cvs by issuing a cvs update -r 1.1.2.56 command in a working directory that already have specific branch of code checked-out.

This commands work correctly if there is an existing version of AFile.java in working directory. But when we get a trace of a file that has no version in working directory the command is not able to acquire the file.

Is there a way to do it?


Solution

  • It is not clear what is your final goal: to bring whole repository into required state (choosen revision of the choosen branch) or to acquire the single file from the repository for further processing. I assume it is the latter.

    Then, you need this command:

    cvs checkout -r <revision> -p filename.ext > ~/tmp/filename.ext
    

    This will dump to stdout specified revision of the specified file (or files), which could be redirected into temporary location and processed.

    Or you could use:

    cvs export -r <revision> -d ~/tmp module/filename.ext
    

    , which would export (part of) repository to specified destination directory.