本文整理汇总了Python中trac.versioncontrol.RepositoryManager.get_real_repositories方法的典型用法代码示例。如果您正苦于以下问题:Python RepositoryManager.get_real_repositories方法的具体用法?Python RepositoryManager.get_real_repositories怎么用?Python RepositoryManager.get_real_repositories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.versioncontrol.RepositoryManager
的用法示例。
在下文中一共展示了RepositoryManager.get_real_repositories方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _sync
# 需要导入模块: from trac.versioncontrol import RepositoryManager [as 别名]
# 或者: from trac.versioncontrol.RepositoryManager import get_real_repositories [as 别名]
def _sync(self, reponame, rev, clean):
rm = RepositoryManager(self.env)
if reponame == '*':
if rev is not None:
raise TracError(_('Cannot synchronize a single revision '
'on multiple repositories'))
repositories = rm.get_real_repositories()
else:
if is_default(reponame):
reponame = ''
repos = rm.get_repository(reponame)
if repos is None:
raise TracError(_("Repository '%(repo)s' not found",
repo=reponame or '(default)'))
if rev is not None:
repos.sync_changeset(rev)
printout(_('%(rev)s resynced on %(reponame)s.', rev=rev,
reponame=repos.reponame or '(default)'))
return
repositories = [repos]
db = self.env.get_db_cnx()
for repos in sorted(repositories, key=lambda r: r.reponame):
printout(_('Resyncing repository history for %(reponame)s... ',
reponame=repos.reponame or '(default)'))
repos.sync(self._sync_feedback, clean=clean)
cursor = db.cursor()
cursor.execute("SELECT count(rev) FROM revision WHERE repos=%s",
(repos.id,))
for cnt, in cursor:
printout(ngettext('%(num)s revision cached.',
'%(num)s revisions cached.', num=cnt))
printout(_('Done.'))
示例2: _do_seed
# 需要导入模块: from trac.versioncontrol import RepositoryManager [as 别名]
# 或者: from trac.versioncontrol.RepositoryManager import get_real_repositories [as 别名]
def _do_seed(self):
# Create a subscription for all existing attachments
cursor = self.env.get_read_db().cursor()
cursor.execute("SELECT DISTINCT type, id FROM attachment")
rows = cursor.fetchall()
for row in rows:
for attachment in Attachment.select(self.env, row[0], row[1]):
Subscription.from_attachment(self.env, attachment)
# Create a subscription for all existing revisions
rm = RepositoryManager(self.env)
repos = rm.get_real_repositories()
for repo in repos:
_rev = repo.get_oldest_rev()
while _rev:
try:
_cs = repo.get_changeset(_rev)
Subscription.from_changeset(self.env, _cs)
except NoSuchChangeset:
pass
_rev = repo.next_rev(_rev)
# Create a subscription for all existing comments
comments = Comments(None, self.env).all()
for comment in comments:
Subscription.from_comment(self.env, comment)
示例3: _sync
# 需要导入模块: from trac.versioncontrol import RepositoryManager [as 别名]
# 或者: from trac.versioncontrol.RepositoryManager import get_real_repositories [as 别名]
def _sync(self, reponame, rev, clean):
rm = RepositoryManager(self.env)
if reponame == "*":
if rev is not None:
raise TracError(_("Cannot synchronize a single revision " "on multiple repositories"))
repositories = rm.get_real_repositories()
else:
if is_default(reponame):
reponame = ""
repos = rm.get_repository(reponame)
if repos is None:
raise TracError(_("Repository '%(repo)s' not found", repo=reponame or "(default)"))
if rev is not None:
repos.sync_changeset(rev)
printout(_("%(rev)s resynced on %(reponame)s.", rev=rev, reponame=repos.reponame or "(default)"))
return
repositories = [repos]
for repos in sorted(repositories, key=lambda r: r.reponame):
printout(_("Resyncing repository history for %(reponame)s... ", reponame=repos.reponame or "(default)"))
repos.sync(self._sync_feedback, clean=clean)
for (cnt,) in self.env.db_query("SELECT count(rev) FROM revision WHERE repos=%s", (repos.id,)):
printout(ngettext("%(num)s revision cached.", "%(num)s revisions cached.", num=cnt))
printout(_("Done."))
示例4: install
# 需要导入模块: from trac.versioncontrol import RepositoryManager [as 别名]
# 或者: from trac.versioncontrol.RepositoryManager import get_real_repositories [as 别名]
#.........这里部分代码省略.........
parser.set('notification', param_name.replace('-', '_'), value)
###############
# Plugins setup
###############
# If one repository use Mercurial, hook its plugin
if 'hg' in repo_types:
parser.set('components', 'tracext.hg.*', 'enabled')
# Configure the NavAdd plugin
menu_items = cleanMultiParams(options.get('additional-menu-items', ''))
item_list = []
for item in menu_items:
item_title = item[0]
item_url = item[1]
item_id = getId(item_title)
item_list.append((item_id, item_title, item_url))
if item_list > 0:
parser.set('components', 'navadd.*', 'enabled')
if 'navadd' not in parser.sections():
parser.add_section('navadd')
parser.set('navadd', 'add_items', ','.join([i[0] for i in item_list]))
for (uid, title, url) in item_list:
parser.set('navadd', '%s.target' % uid, 'mainnav')
parser.set('navadd', '%s.title' % uid, title)
parser.set('navadd', '%s.url' % uid, url)
# Enable and setup time tracking
time_tracking = options.get('time-tracking-plugin', 'disabled').strip().lower() == 'enabled'
if time_tracking:
parser.set('components', 'timingandestimationplugin.*', 'enabled')
# Enable and setup the stat plugin
stats = options.get('stats-plugin', 'disabled').strip().lower() == 'enabled'
if stats:
parser.set('components', 'tracstats.*', 'enabled')
#######################
# Final upgrades & sync
#######################
# Apply custom parameters defined by the user
custom_params = cleanMultiParams(options.get('trac-ini-additional', ''))
for param in custom_params:
if len(param) == 3:
section = param[0]
if section not in parser.sections():
parser.add_section(section)
parser.set(section, param[1], param[2])
# Write the final trac.ini
parser.write(open(trac_ini, 'w'))
# Reload the environment
env.shutdown()
trac = TracAdmin(location)
env = trac.env
# Set custom permissions
perm_sys = PermissionSystem(env)
for cperm in cleanMultiParams(options.get('permissions', '')):
if len(cperm) == 2:
user = cperm[0]
current_user_perms = perm_sys.get_user_permissions(user)
perm_list = [p.upper() for p in cperm[1].split(' ') if len(p)]
for perm in perm_list:
if perm not in current_user_perms:
perm_sys.grant_permission(user, perm)
# Upgrade Trac instance to keep it fresh
needs_upgrade = env.needs_upgrade()
force_upgrade = getBool(options.get('force-instance-upgrade', 'False'))
if needs_upgrade or force_upgrade:
env.upgrade(backup=True)
# Force repository resync
repo_resync = getBool(options.get('force-repos-resync', 'False'))
if repo_resync:
rm = RepositoryManager(env)
repositories = rm.get_real_repositories()
for repos in sorted(repositories, key=lambda r: r.reponame):
repos.sync(clean=True)
# Upgrade default wiki pages embedded in Trac instance
wiki_upgrade = getBool(options.get('wiki-doc-upgrade', 'False'))
if wiki_upgrade:
# Got the command below from trac/admin/console.py
pages_dir = pkg_resources.resource_filename('trac.wiki',
'default-pages')
WikiAdmin(env).load_pages( pages_dir
, ignore=['WikiStart', 'checkwiki.py']
, create_only=['InterMapTxt']
)
# Return files that were created by the recipe. The buildout
# will remove all returned files upon reinstall.
return tuple()