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

发布于 2024-10-19 20:55:19 字数 297 浏览 2 评论 0原文

我有一个项目,其源代码由 CVSNT 控制。

我需要属于某个标签的源文件名和修订版本的列表。 例如:

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

我知道使用 cvs log -rMYTAG > log.txt 我在 log.txt 中获取了我需要的所有信息,然后我可以过滤它来构建我的列表,但是,是否有任何实用程序已经可以满足我的需要?

I have a project with sources under the control of 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

池木 2024-10-26 20:55:19

下面是执行此操作的 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}

请注意,您必须设置 CVSROOT 环境变量,或者从要查询的存储库检出的工作副本中运行此变量。

此外,显示的文件名基于 rlog 输出的“RCS File”属性,即它们仍然包含存储库前缀。如果您想过滤掉它,您可以指定第三个参数,例如,当您的 CVSROOT 类似于 sspi:server:/cvsrepo 时,您可以这样调用:

ListCvsTagRevisions.py MyTag MyModule /cvsrepo/

Hope this有帮助。


注意:如果您需要一个列出工作副本中当前修订版本的脚本,请参阅此答案的编辑历史记录。

, 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]))

请注意,您必须设置 CVSROOT 环境变量,或者从要查询的存储库检出的工作副本中运行此变量。

此外,显示的文件名基于 rlog 输出的“RCS File”属性,即它们仍然包含存储库前缀。如果您想过滤掉它,您可以指定第三个参数,例如,当您的 CVSROOT 类似于 sspi:server:/cvsrepo 时,您可以这样调用:

Hope this有帮助。


注意:如果您需要一个列出工作副本中当前修订版本的脚本,请参阅此答案的编辑历史记录。

Here's a Python script that does this:

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}

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.

Also, the file names displayed are based on the "RCS File" property of the rlog output, i.e. they still contain the repository prefix. If you want to filter that out you can specify a third argument, e.g. when your CVSROOT is something like sspi:server:/cvsrepo then you would call this like:

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.

, 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.

Also, the file names displayed are based on the "RCS File" property of the rlog output, i.e. they still contain the repository prefix. If you want to filter that out you can specify a third argument, e.g. when your CVSROOT is something like sspi:server:/cvsrepo then you would call this like:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文