本文整理汇总了Python中trac.versioncontrol.api.RepositoryManager.get_default_repository方法的典型用法代码示例。如果您正苦于以下问题:Python RepositoryManager.get_default_repository方法的具体用法?Python RepositoryManager.get_default_repository怎么用?Python RepositoryManager.get_default_repository使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.versioncontrol.api.RepositoryManager
的用法示例。
在下文中一共展示了RepositoryManager.get_default_repository方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _format_link
# 需要导入模块: from trac.versioncontrol.api import RepositoryManager [as 别名]
# 或者: from trac.versioncontrol.api.RepositoryManager import get_default_repository [as 别名]
def _format_link(self, formatter, ns, match, label, fullmatch=None):
if ns == 'log1':
groups = fullmatch.groupdict()
it_log = groups.get('it_log')
revs = groups.get('log_revs')
path = groups.get('log_path') or '/'
target = '%s%[email protected]%s' % (it_log, path, revs)
# prepending it_log is needed, as the helper expects it there
intertrac = formatter.shorthand_intertrac_helper(
'log', target, label, fullmatch)
if intertrac:
return intertrac
path, query, fragment = formatter.split_link(path)
else:
assert ns in ('log', 'log2')
if ns == 'log':
match, query, fragment = formatter.split_link(match)
else:
query = fragment = ''
match = ''.join(reversed(match.split('/', 1)))
path = match
revs = ''
if self.LOG_LINK_RE.match(match):
indexes = [sep in match and match.index(sep) for sep in ':@']
idx = min([i for i in indexes if i is not False])
path, revs = match[:idx], match[idx+1:]
rm = RepositoryManager(self.env)
try:
reponame, repos, path = rm.get_repository_by_path(path)
if not reponame:
reponame = rm.get_default_repository(formatter.context)
if reponame is not None:
repos = rm.get_repository(reponame)
if repos:
if 'LOG_VIEW' in formatter.perm:
reponame = repos.reponame or None
path = path or '/'
revranges = RevRanges(repos, revs)
if revranges.has_ranges():
href = formatter.href.log(reponame, path,
revs=unicode(revranges))
else:
# try to resolve if single rev
repos.normalize_rev(revs)
href = formatter.href.log(reponame, path,
rev=revs or None)
if query and '?' in href:
query = '&' + query[1:]
return tag.a(label, class_='source',
href=href + query + fragment)
errmsg = _("No permission to view change log")
elif reponame:
errmsg = _("Repository '%(repo)s' not found", repo=reponame)
else:
errmsg = _("No default repository defined")
except TracError, e:
errmsg = to_unicode(e)
示例2: _format_link
# 需要导入模块: from trac.versioncontrol.api import RepositoryManager [as 别名]
# 或者: from trac.versioncontrol.api.RepositoryManager import get_default_repository [as 别名]
def _format_link(self, formatter, ns, match, label, fullmatch=None):
if ns == "log1":
groups = fullmatch.groupdict()
it_log = groups.get("it_log")
revs = groups.get("log_revs")
path = groups.get("log_path") or "/"
target = "%s%[email protected]%s" % (it_log, path, revs)
# prepending it_log is needed, as the helper expects it there
intertrac = formatter.shorthand_intertrac_helper("log", target, label, fullmatch)
if intertrac:
return intertrac
path, query, fragment = formatter.split_link(path)
else:
assert ns in ("log", "log2")
if ns == "log":
match, query, fragment = formatter.split_link(match)
else:
query = fragment = ""
match = "".join(reversed(match.split("/", 1)))
path = match
revs = ""
if self.LOG_LINK_RE.match(match):
indexes = [sep in match and match.index(sep) for sep in ":@"]
idx = min([i for i in indexes if i is not False])
path, revs = match[:idx], match[idx + 1 :]
rm = RepositoryManager(self.env)
try:
reponame, repos, path = rm.get_repository_by_path(path)
if not reponame:
reponame = rm.get_default_repository(formatter.context)
if reponame is not None:
repos = rm.get_repository(reponame)
if repos:
if "LOG_VIEW" in formatter.perm:
reponame = repos.reponame or None
path = path or "/"
revranges = RevRanges(repos, revs)
if revranges.has_ranges():
href = formatter.href.log(reponame, path, revs=unicode(revranges))
else:
# try to resolve if single rev
repos.normalize_rev(revs)
href = formatter.href.log(reponame, path, rev=revs or None)
if query and "?" in href:
query = "&" + query[1:]
return tag.a(label, class_="source", href=href + query + fragment)
errmsg = _("No permission to view change log")
elif reponame:
errmsg = _("Repository '%(repo)s' not found", repo=reponame)
else:
errmsg = _("No default repository defined")
except TracError as e:
errmsg = to_unicode(e)
return tag.a(label, class_="missing source", title=errmsg)