How do I identify what branches exist in CVS?

情到浓时终转凉″ 提交于 2019-12-03 08:28:14

问题


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
$

回答1:


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



回答2:


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.




回答3:


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

$cvs.exe rlog -h -l -b module1



回答4:


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.




回答5:


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
}


来源:https://stackoverflow.com/questions/566093/how-do-i-identify-what-branches-exist-in-cvs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!