📄 cvsdbadmin
字号:
#!/usr/bin/env python# -*- Mode: python -*-## Copyright (C) 2000 The ViewCVS Group. All Rights Reserved.## By using this file, you agree to the terms and conditions set forth in# the LICENSE.html file which can be found at the top level of the ViewCVS# distribution or at http://www.lyra.org/viewcvs/license-1.html.## Contact information:# Greg Stein, PO Box 760, Palo Alto, CA, 94302# gstein@lyra.org, http://www.lyra.org/viewcvs/## -----------------------------------------------------------------------## administrative program for CVSdb; this is primarily# used to add/rebuild CVS repositories to the database## -----------------------------------------------------------------------############################################################################ INSTALL-TIME CONFIGURATION## These values will be set during the installation process. During# development, they will remain None.#LIBRARY_DIR = NoneCONF_PATHNAME = None# Adjust sys.path to include our library directoryimport sysif LIBRARY_DIR: sys.path.insert(0, LIBRARY_DIR)else: sys.path[:0] = ['../lib'] # any other places to look?######################################################################### import osimport stringimport cvsdbdef UpdateFile(db, repository, path): try: commit_list = cvsdb.GetUnrecordedCommitList(repository, path) except cvsdb.error, e: print '[ERROR] %s' % (e) return print '[%s[%d new commits]]' % (path, len(commit_list)), ## add the commits into the database for commit in commit_list: db.AddCommit(commit) sys.stdout.write('.') sys.stdout.flush() printdef RecurseUpdate(db, repository, directory): for path in os.listdir(directory): path = os.path.join(directory, path) if os.path.islink(path): continue if os.path.isdir(path): RecurseUpdate(db, repository, path) continue if os.path.isfile(path): if path[-2:] == ',v': UpdateFile(db, repository, path) def CommandUpdate(): ## connect to the database we are updating db = cvsdb.ConnectDatabase() repository = sys.argv[2] RecurseUpdate(db, repository, repository)def RebuildFile(db, repository, path): try: commit_list = cvsdb.GetCommitListFromRCSFile(repository, path) except cvsdb.error, e: print '[ERROR] %s' % (e) return print '[%s[%d commits]]' % (path, len(commit_list)), ## add the commits into the database for commit in commit_list: db.AddCommit(commit) sys.stdout.write('.') sys.stdout.flush() printdef RecurseRebuild(db, repository, directory): for path in os.listdir(directory): path = os.path.join(directory, path) if os.path.islink(path): continue if os.path.isdir(path): RecurseRebuild(db, repository, path) continue if os.path.isfile(path): if path[-2:] == ',v': RebuildFile(db, repository, path) def CommandRebuild(): ## connect to the database we are updating db = cvsdb.ConnectDatabase() repository = sys.argv[2] RecurseRebuild(db, repository, repository)def usage(): print 'Usage: %s <command> [arguments]' % (sys.argv[0]) print 'Preforms administrative functions for the CVSdb database' print 'Commands:' print ' rebuild <repository> rebuilds the CVSdb database' print ' for all files in the repository' print ' update <repository> updates the CVSdb database for' print ' all unrecorded commits' print sys.exit(1)## mainif __name__ == '__main__': ## check that a command was given if len(sys.argv) < 2: usage() ## set the handler function for the command command = sys.argv[1] if string.lower(command) == 'rebuild': commandFunction = CommandRebuild elif string.lower(command) == 'update': commandFunction = CommandUpdate else: print 'ERROR: unknown command %s' % (command) usage() ## run command try: commandFunction() except KeyboardInterrupt: print print '** break **' sys.exit(0)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -