Get revision number of a tagged file in WinCvs
Asked Answered
A

1

6

This seems like it should be so simple, but I can't find any solution that appears to work...

I need a CVS command that given the name of a tag that you have applied to a file, it will give you the revision number.


CVS Tree structure:

(filename)
    |
    +--> 1.1-----(branch)
          |         |
          |      1.1.1.1---(tag1)
          |         |
          |      1.1.1.2---(tag2)
          |         |
          |      1.1.1.3---(tag3)
          |         |
          |         :
         1.2
          |
          |
          :

For example: Using a CVS command, given the tag name "tag2", how can I get CVS to give me the revision number "1.1.1.2"?


The closest thing I can find is using the log command with the -Q flag, but that still gives me much more information than I need.

ex: cvs -Q log -h filename

Passing the tagname to the log command seems to have no effect.


CVS Version information:

enter image description here


My current solution is to use a perl script to parse the output from the log command but there has to be a simpler way...

Animalize answered 13/5, 2015 at 21:0 Comment(0)
F
1

Passing a tag name (with a -r option) to the log command does have an effect, just not a particularly useful one and it's effect is hidden by "-h".

Usually the easiest way to get a revision number for your VERSION file (the normal use-case for this) is to include a keyword in it; ie:

# Thu 21 May 08:40:59 BST 2015
THISREV="$Revision$"

Note: to get a repository version number this VERSION file must be committed every time you make a commit to the repo.

If you need a revision for a specific file then you're basically falling back on scripting from the "symbolic names" part of the log. So for r-1-0-0 you do this:

cvs -Q log -h VERSION | awk '/^\tr-1-0-0:/ {print $NF;}'

There's no direct equivalent of the git describe command.

Frodine answered 21/5, 2015 at 7:57 Comment(4)
Unfortunately I am not the one creating the files that are going into the repository so I have no way of enforcing that a version line be added within each file. Right now I am using a Perl script to parse the log command output, but I was just really hoping there was a faster easier way.Animalize
Although you didn't fully answer my question you did come up with a solution so I have awarded the bounty to you. For now I will stick to using a Perl script since your suggestion isn't possible for me.Animalize
I've accepted this answer because the awk solution does work for me on Linux and its highly unlikely that this will get any more responses. I would like a solution that works on windows though.Animalize
The git-bash that's installed as a standard part of the plain git tools comes with a compile of gawk as should all the msys compilations. The mawk.exe program has been available as a native win32 program for many years. Then of course there's the cygwin stuff, which IMO would be serious overkill (and complicated) for "just an awk command".Frodine

© 2022 - 2024 — McMap. All rights reserved.