Get latest revision number of a file from cvs repository - version-control

Is there a way to know the latest revision number of a file in cvs repository without checking out that file.
The exact problem is, suppose I know the name of a file which is in cvs repo. Let's call it file1.text.
So, is there any command or any way by which I can search repo for that file and get the latest revision number of that file?

You can use CVS log and give a revision as "starting point":
$ cvs log -r{REVISION}:: file1.text
The -r{REVISION}:: will only search for revisions after {REVISION} (can be a number or tag).
If you don't have a working copy, you can use rls cvs command. With -l argument, it will print the version of files.
$ cvs rls -l MyModule/path/to/the/file
You can use -r to specify a branch.

Here's the command to use:
cvs history -a -c -l module/file1.text
This will display the version and the date the file was last modified. This doesn't require the module or file checked out.

Related

How to switch to an old revision of the entire project?

For what I know, CVS is not like git and svn that you can switch back to an older version of an entire repo code.
The best I tried is I checkout a date (some days ago), using Eclipse. But it checked out a very old version. I'm sure to have inserted the correct date.
You can return to an old version of the entire repo code by running the following command from the root directory of your repo:
cvs update -r <TAG name>
where TAG name is the name of a TAG which was previously created on the entire repo using:
cvs tag -F <TAG name>
In cvs, a TAG is a list of files and their cvs revision. So using the tag command creates that list, and using the update command (with -r switch) is asking to return to the same file revisions which existed when tag was created.
One more important note, to return to the latest revision (head) of all files in you repo, use:
cvs update -A

How to search commit history?

Is there any way to find when the function "_make_parser_function" was introduced in the file pandas/pandas/io/parsers.py?
I tried to search within commit history, but could not find the exact date on which this change was introduced. I guess this function was not available in older versions of pandas.
https://github.com/pandas-dev/pandas/commits/71334472766fc95e7dc828dce2bfe798f6bb19dc?before=71334472766fc95e7dc828dce2bfe798f6bb19dc+35&path%5B%5D=pandas&path%5B%5D=io&path%5B%5D=parsers.py
Try -L option
# git log -L :myfunction:path/to/myfile.c
git log -L :_make_parser_function:pandas/io/parsers.py

Perforce command line head revision file

What is the command line syntax to check whether this workspace currently has the latest revision of a certain file?
The command:
p4 sync -n
will preview the sync operation. This will tell you which files would be updated were you to use the actual command.
The command:
p4 have [file]
will tell you the version of the file you currently have. This coupled with:
p4 fstat -T "headRev" [file]
which tells you the head revision number, will tell you whether you have the latest version or not.
It's worth noting that all Perforce commands have a preview option that tell you what they would do. This allows you to verify you've got the correct command without fear of corrupting your workspace or depot.

Retrieve old version of a file without changing working copy parent

How do you get a copy of an earlier revision of a file in Mercurial without making that the new default working copy of the file in your workspace?
I've found the hg revert command and I think it does what I want but I'm not sure.
I need to get a copy of an earlier revision of my code to work with for a few minutes. But I don't want to disturb the current version which is working fine.
So I was going to do this:
hg revert -r 10 myfile.pls
Is there a way to output it to a different directory so my current working version of the file is not disturbed? Something like:
hg revert -r 10 myfile.pls > c:\temp\dump\myfile_revision10.pls
The cat command can be used to retrieve any revision of a file:
$ hg cat -r 10 myfile.pls
You can redirect the output to another file with
$ hg cat -r 10 myfile.pls > old.pls
or by using the --output flag. If you need to do this for several files, then take a look at the archive command, which can do this for an entire project, e.g.,
$ hg archive -r 10 ../revision-10
This creates the folder revision-10 which contains a snapshot of your repository as it looked in revision 10.
However, most of the time you should just use the update command to checkout an earlier revision. Update is the command you use to bring the working copy up to date after pulling in new changes, but the command can also be used to make your working copy outdated if needed. So
$ hg update -r 10 # go back
(look at your files, test, etc...)
$ hg update # go back to the tip
The command you use is this:
hg cat -r 10 myfile.pls > C:\temp\dump\myfile_revision10.pls
Knowing a bit of Unix helps with Mercurial commands. Perhaps cat should have a built in alias print or something similar.

Mercurial: Get non-versioned copy of an earlier version of a file

How do I get a non-versioned copy of an older version of a file from a mercurial repository?
Edit: I have changed somefile.png (binary file) in my local copy. I am looking for a command which will allow me to get an earlier version of somefile.png so that I can compare it with my modified copy (using an image viewer) before I commit changes. How can I do that?
The command you are looking for is cat
hg cat [OPTION]... FILE...
output the current or given revision of files
hg cat -o outputfile.png -r revision somefile.png
You can then compare somefile.png with outputfile.png
If you mean: what is the equivalent of svn export?, that would be:
hg archive ..\project.export
See also this TipsAndTrick section
Make a clean copy of a source tree, like CVS export
hg clone source export
rm -rf export/.hg
or using the archive command
cd source
hg archive ../export
The same thing, but for a tagged release:
hg clone --noupdate source export-tagged
cd export-tagged
hg update mytag
rm -rf .hg
or using the archive command
cd source
hg archive -r mytag ../export-tagged
There's a tip on the hgtip that might get you most of the way there:
Merging binary files
While it specifically talks about merging, the diff stuff should be generic enough to do it outside a merge...
I'm not sure I understand the question. You you could just copy it somewhere else using the normal file copy tools of your operating system.