Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 250
Tahir Akhtar Avatar asked Oct 10 '08 05:10

Tahir Akhtar


4 Answers

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.

like image 121
ADEpt Avatar answered Oct 22 '22 11:10

ADEpt


cvs --help

tells you that you can use the -H arg to view help on a specific CVS command like so:

$ cvs -H checkout
Usage:
  cvs checkout [-ANPRcflnps] [-r rev] [-D date] [-d dir]
    [-j rev1] [-j rev2] [-k kopt] modules...
        -A      Reset any sticky tags/date/kopts.
        -N      Don't shorten module paths if -d specified.
        -P      Prune empty directories.
        -R      Process directories recursively.
        -c      "cat" the module database.
        -f      Force a head revision match if tag/date not found.
        -l      Local directory only, not recursive
        -n      Do not run module program (if any).
        -p      Check out files to standard output (avoids stickiness).
        -s      Like -c, but include module status.
        -r rev  Check out revision or tag. (implies -P) (is sticky)
        -D date Check out revisions as of date. (implies -P) (is sticky)
        -d dir  Check out into dir instead of module name.
        -k kopt Use RCS kopt -k option on checkout. (is sticky)
        -j rev  Merge in changes made between current revision and rev.
(Specify the --help global option for a list of other help options)

... teach a person how to fish ... :)

like image 20
Jess Avatar answered Oct 22 '22 11:10

Jess


I have tried as below way

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

It was giving error like

cvs checkout: cannot find module `filename.ext` -ignored.

So i have done as below way

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

Now it worked fine.

like image 2
Jeegar Patel Avatar answered Oct 22 '22 10:10

Jeegar Patel


One solution would be to change the tool to issue a "cvs co" for the file, specifying the revision as is being now with the update. The checkout command would have to be done from the top of your tree, not in the directory containing the file. I've come across similar cases where the update fails to find a new file, requiring a checkout of the file as I've described.

like image 1
Jason Etheridge Avatar answered Oct 22 '22 09:10

Jason Etheridge