简体   繁体   English

CVSNT:从标签到文件名和修订列表

[英]CVSNT: from a tag to a list of file names and revisions

I have a project with sources under the control of CVSNT. 我有一个由CVSNT控制的项目。

I need a list of source file names and revisions belonging to a certain tag. 我需要一个属于某个标签的源文件名称和修订列表。 For example: 例如:

the tag MYTAG is:
myproject/main.cpp 1.5.2.3
myproject/myclass.h 1.5.2.1

I know that with cvs log -rMYTAG > log.txt I get in log.txt all the information I need and then I can filter it to build my list, but, is there any utility which already do what I need? 我知道使用cvs log -rMYTAG > log.txt可以获取log.txt我需要的所有信息,然后可以对其进行过滤以构建我的列表,但是,是否有任何实用工具已经在满足我的需要?

Here's a Python script that does this: 这是执行此操作的Python脚本:

import sys, os, os.path
import re, string

def runCvs(args):
  f_in, f_out, f_err = os.popen3('cvs '+string.join(args))
  out = f_out.read()
  err = f_err.read()
  f_out.close()
  f_err.close()
  code = f_in.close()
  if not code: code = 0
  return code, out, err

class RevDumper:
  def parseFile(self, rex, filelog):
    m = rex.search(filelog)
    if m:
      print '%s\t%s' % (m.group(1), m.group(2))

  def filterOutput(self, logoutput, repoprefix):
    rex = re.compile('^={77}$', re.MULTILINE)
    files = rex.split(logoutput)
    rex = re.compile('RCS file: %s(.*),v[^=]+selected revisions: [^0][^=]+revision ([0-9\.]+)' % repoprefix, re.MULTILINE)
    for file in files:
      self.parseFile(rex, file)

  def getInfo(self, tag, module, repoprefix):
    args = ['-Q', '-z9', 'rlog', '-S', '-N', '-r'+tag, module] # remove the -S if you're using an older version of CVS
    code, out, err = runCvs(args)
    if code == 0:
      self.filterOutput(out, repoprefix)
    else:
      sys.stderr.write('CVS returned %d\n%s\n' % (code, err))

if len(sys.argv) > 2:
  tag = sys.argv[1]
  module = sys.argv[2]
  if len(sys.argv) > 3:
    repoprefix = sys.argv[3]
  else:
    repoprefix = ''
  RevDumper().getInfo(tag, module, repoprefix)
else:
  sys.stderr.write('Syntax: %s TAG MODULE [REPOPREFIX]' % os.path.basename(sys.argv[0]))

Note that you either have to have a CVSROOT environment variable set or run this from inside a working copy checked out from the repository you want to query. 请注意,您必须设置CVSROOT环境变量,或者从要查询的存储库中检出的工作副本内部运行此变量。

Also, the file names displayed are based on the "RCS File" property of the rlog output, ie they still contain the repository prefix. 同样,显示的文件名基于rlog输出的“ RCS File”属性,即它们仍包含存储库前缀。 If you want to filter that out you can specify a third argument, eg when your CVSROOT is something like sspi:server:/cvsrepo then you would call this like: 如果要过滤掉该参数,则可以指定第三个参数,例如,当CVSROOT类似于sspi:server:/cvsrepo您可以这样称呼:

ListCvsTagRevisions.py MyTag MyModule /cvsrepo/

Hope this helps. 希望这可以帮助。


Note: If you need a script that lists the revisions currently in your working copy, see the edit history of this answer. 注意:如果需要一个脚本,该脚本列出您的工作副本中当前的修订,请参阅此答案的编辑历史记录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM