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

6

9

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?

Voluntary answered 10/10, 2008 at 5:35 Comment(0)
F
25

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.

Floccose answered 10/10, 2008 at 6:21 Comment(3)
Thanks. I am going with cvs co -r <revision> /module/path/to/file.txt without the -p optionVoluntary
If you don't use the -p option it will set the sticky flag, so all fugure checkouts will use the old revision.Warehouse
The checkout command doesn't work for me: it says "module not found" for the file I specify.Warehouse
H
3

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 ... :)

Haffner answered 22/4, 2013 at 15:19 Comment(3)
Thanks for the fishing tip :P This question was asked at Oct 10 '08. A lot of water has passed under the bridge since then :)Voluntary
Agreed, but stack overflow is a resource for many people. I googled and found this question. It was helpful, but it does not explain what -p does nor what other options are available. I hope this answer will help other people. Regards!Haffner
Though it would be better to edit an existing answer and add the explanation.Voluntary
W
2

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.

Written answered 3/12, 2015 at 9:58 Comment(1)
Yes, I had this error too. I have no idea what my module name is. I'm sure I could figure it out, but it seems ridiculous to have to do that just to check out an old version of one file. See my solution that doesn't require figuring out the module name.Warehouse
S
1

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.

Silvasilvain answered 10/10, 2008 at 6:7 Comment(1)
Thanks. I tried that immediately after posting the question and it worked.Voluntary
W
1

This is the only way that works for me, as the checkout command always gives a "module not found" error:

cvs diff -r <revision> <file> > /tmp/patch
cp <file> /tmp
cd /tmp
patch -R < patch

It seems that cvs dropped the ball on this.

Warehouse answered 15/3, 2017 at 15:49 Comment(0)
B
0

I did this:

cd <to_your_file_directory>
mv user.cpp user.cpp.bak
cvs update -r 1.55 user.cpp
Bourges answered 28/3, 2022 at 4:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.