How do I identify what branches exist in CVS?
Asked Answered
A

6

24

I have a legacy CVS repository which shall be migrated to Perforce.

For each module, I need to identify what branches exist in that module.

I just want a list of branch names, no tags. It must be a command line tool, for scripting reasons.

For example (assuming there is a cvs-list-branches.sh script):

$ ./cvs-list-branches.sh module1
HEAD
dev_foobar
Release_1_2
Release_1_3
$
Adjust answered 19/2, 2009 at 16:27 Comment(0)
W
26

As a quick hack:) The same stands true for rlog.

cvs log -h | awk -F"[.:]" '/^\t/&&$(NF-1)==0{print $1}' | sort -u

Improved version as per bdevay, hiding irrelevant output and left-aligning the result:

cvs log -h 2>&1 | awk -F"[.:]" '/^\t/&&$(NF-1)==0{print $1}' | awk '{print $1}' | sort -u
Willman answered 4/5, 2010 at 12:6 Comment(3)
Small beautify: cvs log -h 2>&1 | awk -F"[.:]" '/^\t/&&$(NF-1)==0{print $1}' | awk '{print $1}' | sort -u It hides also the lines begin with "cvs log: " and aligns the result to the left.Vaulting
nice touch for using 2>&1 and hiding irrelevant dataAttitudinize
Could someone please elaborate what his actually does? I mean, what does it look for in the output of cvs log -h? At least to me that's not obvious.Trap
V
15

You could simply parse log output of cvs log -h. For each file there will be a section named Symbolic names :. All tags listed there that have a revision number that contains a zero as the last but one digit are branches. E.g.:

$ cvs log -h

Rcs file : '/cvsroot/Module/File.pas,v'
Working file : 'File.pas'
Head revision : 1.1
Branch revision : 
Locks : strict
Access :
Symbolic names :
    1.1 : 'Release-1-0'
    1.1.2.4 : 'Release-1-1'
    1.1.0.2 : 'Maintenance-BRANCH'
Keyword substitution : 'kv'
Total revisions : 5
Selected revisions : 0
Description :

===============================================

In this example Maintenance-BRANCH is clearly a branch because its revision number is listed as 1.1.0.2. This is also sometimes called a magic branch revision number.

Vacuous answered 20/2, 2009 at 8:21 Comment(5)
Hi, If there is no such branch with a magic branch revision number, what does that mean?Ultimately
cvs log -h gives lots of output if you have lots of files. To tone it down, use cvs log pom.xml or something like that to just get the log of one file. (This will work in all situations, right?)Ampliate
@LimitedAtonement : Yep, it does. When I wrote "parse the output of" I was assuming that one would write some sort of script to pre-process the output before consuming it with the naked eye... ;)Vacuous
I see Branch revision : in that output. It's a bit confusing that this seems to play no role when looking for branches. Can someone please explain what that entry is for then?Trap
@Trap : If I remember correctly (it's been a while since I actively used CVS by now and I no longer have a live instance to quickly check against) that line would indicate the currently checked out branch revision (if any - apparently none in my example, i.e. the file is currently checked out on TRUNK)Vacuous
M
5

This will bring up tags too, but tags and branches are basically the same in CVS.

$cvs.exe rlog -h -l -b module1
Maecenas answered 19/2, 2009 at 16:45 Comment(5)
Is there a simple way to filter out tags? Our CI server produces lots and lots of tags every night... Or is CVS really that stupid so that there is no way of telling the difference between a branch and a tag?Adjust
Other than parsing the version numbers, no there is no way of telling. You have to remember that branches are something that CVS added to RCS, the real version control under the hood.Maecenas
So, how would one parse the version numbers then in order to filter out tags and only keep branches?Trap
@Trap I haven't used CVS in over 10 years, so I think if you want to get an answer to that, I would recommend asking it as proper question.Maecenas
Nevermind, I've already found the information. There are two main rules: "branch numbers consist of an odd number of dot-separated decimals" and "CVS sometimes inserts an extra 0 in the second rightmost position".Trap
U
1

I have a small collection of "handy" korn shell functions one of which fetches tags for a given file. I've made a quick attempt to adapt it to do what you want. It simply does some seding/greping of the (r)log output and lists versions which have ".0." in them (which indicates that it's a branch tag):

get_branch_tags()
{
    typeset FILE_PATH=$1

    TEMP_TAGS_INFO=/tmp/cvsinfo$$

    /usr/local/bin/cvs rlog $FILE_PATH 1>${TEMP_TAGS_INFO} 2>/dev/null

    TEMPTAGS=`sed -n '/symbolic names:/,/keyword substitution:/p' ${TEMP_TAGS_INFO} | grep "\.0\." | cut -d: -f1 | awk '{print $1}'`
    TAGS=`echo $TEMPTAGS | tr ' ' '/'`
    echo ${TAGS:-NONE}
    rm -Rf $TEMP_TAGS_INFO 2>/dev/null 1>&2
}
Underprop answered 9/4, 2009 at 11:8 Comment(0)
D
0

with Wincvs (Gui client for windows) this is trivial, a right click will give you any branches and tags the files have.

Trough a shell you may use cvs log -h -l module.

Dibrin answered 19/2, 2009 at 16:48 Comment(1)
and its there! A just added the wincvs info so it could be useful to other people.Dibrin
R
0

Check for the very first file created and committed in the repository. Open the file in server which will list all the Tags and Branches together

Rutger answered 25/9, 2020 at 13:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.