[英]CVSNT: from a tag to a list of file names and revisions
我有一個由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
我需要的所有信息,然后可以對其進行過濾以構建我的列表,但是,是否有任何實用工具已經在滿足我的需要?
這是執行此操作的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]))
請注意,您必須設置CVSROOT
環境變量,或者從要查詢的存儲庫中檢出的工作副本內部運行此變量。
同樣,顯示的文件名基於rlog
輸出的“ RCS File”屬性,即它們仍包含存儲庫前綴。 如果要過濾掉該參數,則可以指定第三個參數,例如,當CVSROOT
類似於sspi:server:/cvsrepo
您可以這樣稱呼:
ListCvsTagRevisions.py MyTag MyModule /cvsrepo/
希望這可以幫助。
注意:如果需要一個腳本,該腳本列出您的工作副本中當前的修訂,請參閱此答案的編輯歷史記錄。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.