本文整理汇总了Python中trac.versioncontrol.RepositoryManager.get_repository_by_path方法的典型用法代码示例。如果您正苦于以下问题:Python RepositoryManager.get_repository_by_path方法的具体用法?Python RepositoryManager.get_repository_by_path怎么用?Python RepositoryManager.get_repository_by_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.versioncontrol.RepositoryManager
的用法示例。
在下文中一共展示了RepositoryManager.get_repository_by_path方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _process_changeset_view
# 需要导入模块: from trac.versioncontrol import RepositoryManager [as 别名]
# 或者: from trac.versioncontrol.RepositoryManager import get_repository_by_path [as 别名]
def _process_changeset_view(self, request):
request.perm.require('CHANGESET_VIEW')
new = request.args.get('new')
new_path = request.args.get('new_path')
old = request.args.get('old')
repository_name = request.args.get('reponame')
# -- support for the revision log ''View changes'' form,
# where we need to give the path and revision at the same time
if old and '@' in old:
old, old_path = old.split('@', 1)
if new and '@' in new:
new, new_path = new.split('@', 1)
manager = RepositoryManager(self.env)
if repository_name:
repository = manager.get_repository(repository_name)
else:
repository_name, repository, new_path = manager.get_repository_by_path(new_path)
repository_url = repository.params.get('url', '')
if _valid_github_request(request) and re.match(r'^https?://(?:www\.)?github\.com/', repository_url):
url = repository_url.rstrip('/') + '/'
if old:
url += 'compare/' + old + '...' + new
else:
url += 'commit/' + new
request.redirect(url)
else:
return _old_process_changeset_view(self, request)
示例2: _process_browser_view
# 需要导入模块: from trac.versioncontrol import RepositoryManager [as 别名]
# 或者: from trac.versioncontrol.RepositoryManager import get_repository_by_path [as 别名]
def _process_browser_view(self, request):
request.perm.require('BROWSER_VIEW')
preselected = request.args.get('preselected')
if preselected and (preselected + '/').startswith(request.href.browser() + '/'):
request.redirect(preselected)
elif request.path_info.startswith('/browser') and _valid_github_request(request):
path = request.args.get('path', '/')
rev = request.args.get('rev', '')
if rev.lower() in ('', 'head'):
rev = 'master'
manager = RepositoryManager(self.env)
repository_name, repository, path = manager.get_repository_by_path(path)
repository_url = repository.params.get('url', '')
if re.match(r'^https?://(?:www\.)?github\.com/', repository_url):
url = repository_url.rstrip('/') + '/blob/' + rev + '/' + path
request.redirect(url)
else:
return _old_process_browser_view(self, request)
else:
return _old_process_browser_view(self, request)
示例3: for_request
# 需要导入模块: from trac.versioncontrol import RepositoryManager [as 别名]
# 或者: from trac.versioncontrol.RepositoryManager import get_repository_by_path [as 别名]
def for_request(cls, env, req, create=False):
"""
Return a **single** subscription for a HTTP request.
"""
rm = RepositoryManager(env)
dict_ = {
'user': req.authname,
'type': req.args.get('realm'),
'path': '',
'rev': '',
'repos': '',
}
path = req.args.get('path') or ''
if dict_['type'] == 'attachment':
dict_['path'] = path
if dict_['type'] == 'changeset':
parts = [p for p in path.split('/') if p]
dict_['rev'] = parts[0]
dict_['repos'] = parts[1]
if dict_['type'] == 'browser':
reponame, repos, path = rm.get_repository_by_path(path)
dict_['path'] = '/' if len(path) == 0 else path
dict_['rev'] = req.args.get('rev') or ''
dict_['repos'] = reponame
return cls.from_dict(env, dict_, create=create)
示例4: from_comment
# 需要导入模块: from trac.versioncontrol import RepositoryManager [as 别名]
# 或者: from trac.versioncontrol.RepositoryManager import get_repository_by_path [as 别名]
def from_comment(cls, env, comment, user=None, notify=True):
"""
Creates a subscription from a Comment object.
"""
sub = {
'user': user or comment.author,
'type': comment.type,
'notify': notify,
}
# Munge attachments
if comment.type == 'attachment':
sub['path'] = comment.path.split(':')[1]
sub['repos'] = ''
sub['rev'] = ''
# Munge changesets and browser
if comment.type in ('changeset', 'browser'):
rm = RepositoryManager(env)
reponame, repos, path = rm.get_repository_by_path(comment.path)
if comment.type == 'browser':
sub['path'] = path
else:
sub['path'] = ''
sub['repos'] = reponame or '(default)'
try:
_cs = repos.get_changeset(comment.revision)
except NoSuchChangeset:
# Invalid changeset
return None
else:
sub['rev'] = _cs.rev
return cls.from_dict(env, sub)
示例5: for_comment
# 需要导入模块: from trac.versioncontrol import RepositoryManager [as 别名]
# 或者: from trac.versioncontrol.RepositoryManager import get_repository_by_path [as 别名]
def for_comment(cls, env, comment, notify=None):
"""
Return all subscriptions for a comment.
"""
args = {}
if comment.type == 'attachment':
args['type'] = comment.type
args['path'] = comment.path.split(':')[1]
if comment.type == 'changeset':
args['type'] = comment.type
args['rev'] = str(comment.revision)
if comment.type == 'browser':
rm = RepositoryManager(env)
reponame, _, path = rm.get_repository_by_path(comment.path)
args['type'] = ('browser', 'changeset')
args['path'] = (path, '')
args['repos'] = reponame
args['rev'] = (str(comment.revision), '')
return cls.select(env, args, notify)