• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python versioncontrol.RepositoryManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中trac.versioncontrol.RepositoryManager的典型用法代码示例。如果您正苦于以下问题:Python RepositoryManager类的具体用法?Python RepositoryManager怎么用?Python RepositoryManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了RepositoryManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: changeset_added

    def changeset_added(self, repos, changeset):
        newchange = changeset
        repo = RepositoryManager(self.env).repository_dir
        repdir = repo.split('.git')[0]
        changes = list(newchange.get_changes())
        print '....handling wikipages.......'
        for change in changes:
            directory = change[0].split('/')[0]
            filename = change[0].split('/')[1]
            pagename = filename.split('.txt')[0]
            extension = filename.split(pagename)[1]

            if (directory == 'wiki' and extension == '.txt'):
                path = repdir + change[0]

                if change[2] == 'edit' or change[2] == 'add':
                    self.add_wiki_file_to_trac(pagename, path)

                elif change[2] == 'delete':
                    self.delete_wiki_page_in_trac(pagename)
                    print (filename + ': wikipage removed.')

                else:
                    print 'Nothing todo.'
            else:
                print 'File was no textfile. Keep going.'
            print '....wikipage handling done......have a nice day :)!'
开发者ID:dhoess,项目名称:geekedit,代码行数:27,代码来源:geekedit.py


示例2: _sync

 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.'))
开发者ID:zjj,项目名称:trac_hack,代码行数:33,代码来源:admin.py


示例3: for_request

    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)
开发者ID:Automattic,项目名称:trac-code-comments-plugin,代码行数:30,代码来源:subscription.py


示例4: expand_macro

 def expand_macro(self, formatter, name, content, args={}):
     reponame = args.get('repository') or ''
     rev = args.get('revision')
     repos = RepositoryManager(self.env).get_repository(reponame)
     try:
         changeset = repos.get_changeset(rev)
         message = changeset.message
         
         # add review status to commit message (
         review = CodeReview(self.env, reponame, rev)
         status = review.encode(review.status)
         message += '\n\n{{{#!html \n'
         message += '<div class="codereviewstatus">'
         message += '  <div class="system-message %s">' % status.lower()
         message += '    <p>Code review status: '
         message += '      <span>%s</span>' % review.status
         message += '    </p>'
         message += '  </div>'
         message += '</div>'
         message += '\n}}}'
         
         rev = changeset.rev
         resource = repos.resource
     except Exception, e:
         message = content
         resource = Resource('repository', reponame)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:26,代码来源:web_ui.py


示例5: match_request

    def match_request(self, request):
        """Match requests which are POST, include a 'commit' argument, and point at an existing repo"""
        if request.method != 'POST':
            return False

        repo_name = _get_repo_name(request.path_info)
        if repo_name is None:
            return False

        repo = RepositoryManager(self.env).get_repository(repo_name)
        if repo is None:
            return False
        repo.close()

        from cgi import parse_qs
        request.args = parse_qs(request.read())
        if request.args.get('commit', request.args.get('payload', None)) is None:
            return False

        ## XXX: evil hack to disable CSRF checking (is there a better way?)
        request._inheaders.insert(0, ('content-type', 'xx'))

        ## Go!
        self.log.info('Handling a beanstalk hook callback for repository [%s]' % repo_name)
        return True
开发者ID:trac-hacks,项目名称:BeanstalkPlugin,代码行数:25,代码来源:BeanstalkPlugin.py


示例6: _do_changeset_added

 def _do_changeset_added(self, reponame, *revs):
     if is_default(reponame):
         reponame = ""
     rm = RepositoryManager(self.env)
     errors = rm.notify("changeset_added", reponame, revs)
     for error in errors:
         printout(error)
开发者ID:pkdevbox,项目名称:trac,代码行数:7,代码来源:admin.py


示例7: expand_macro

 def expand_macro(self, formatter, name, content, args={}):
     reponame = args.get("repository") or ""
     rev = args.get("revision")
     repos = RepositoryManager(self.env).get_repository(reponame)
     try:
         changeset = repos.get_changeset(rev)
         message = changeset.message
         rev = changeset.rev
         resource = repos.resource
     except Exception:
         message = content
         resource = Resource("repository", reponame)
     if formatter.context.resource.realm == "ticket":
         ticket_re = CommitTicketUpdater.ticket_re
         if not any(int(tkt_id) == int(formatter.context.resource.id) for tkt_id in ticket_re.findall(message)):
             return tag.p("(The changeset message doesn't reference this " "ticket)", class_="hint")
     if ChangesetModule(self.env).wiki_format_messages:
         return tag.div(
             format_to_html(
                 self.env, formatter.context.child("changeset", rev, parent=resource), message, escape_newlines=True
             ),
             class_="message",
         )
     else:
         return tag.pre(message, class_="message")
开发者ID:moreati,项目名称:trac-gitsvn,代码行数:25,代码来源:commit_updater.py


示例8: _do_changeset_modified

 def _do_changeset_modified(self, reponame, *revs):
     if is_default(reponame):
         reponame = ''
     rm = RepositoryManager(self.env)
     errors = rm.notify('changeset_modified', reponame, revs)
     for error in errors:
         printout(error)
开发者ID:exocad,项目名称:exotrac,代码行数:7,代码来源:admin.py


示例9: from_comment

    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'):
            if comment.type == 'browser':
                sub['path'] = comment.path
            else:
                sub['path'] = ''
            repo = RepositoryManager(env).get_repository(None)
            try:
                sub['repos'] = repo.reponame
                try:
                    _cs = repo.get_changeset(comment.revision)
                    sub['rev'] = _cs.rev
                except NoSuchChangeset:
                    # Invalid changeset
                    return None
            finally:
                repo.close()

        return cls._from_dict(env, sub)
开发者ID:trainormg,项目名称:trac-code-comments-plugin,代码行数:35,代码来源:subscription.py


示例10: process_request

    def process_request(self, request):
        payload = request.args.get('payload')

        if not payload:
            raise Exception('Payload not found')

        payload = simplejson.loads(payload)

        repository_name = payload['repository']['name']
        repository = self.env.get_repository(repository_name)

        if not repository:
            raise Exception('Repository "%s" not found' % repository_name)

        # CachedRepository
        if repository.repos:
            repository.repos.git.repo.remote('update')
        # Normal repository
        else:
            repository.git.repo.remote('update')

        manager = RepositoryManager(self.env)

        revision_ids = [ commit['id'] for commit in payload['commits'] ]

        try:
            self.env.log.debug('Adding changesets: %s' % revision_ids)
            manager.notify('changeset_added', repository_name, revision_ids)
        except Exception as exception:
            self.env.log.error(exception)

        request.send_response(204)
        request.send_header('Content-Length', 0)
        request.write('')
        raise RequestDone
开发者ID:klas-genestack,项目名称:github-trac,代码行数:35,代码来源:github.py


示例11: _process_changeset_view

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)
开发者ID:klas-genestack,项目名称:github-trac,代码行数:35,代码来源:github.py


示例12: expand_macro

 def expand_macro(self, formatter, name, content, args=None):
     args = args or {}
     reponame = args.get('repository') or ''
     rev = args.get('revision')
     repos = RepositoryManager(self.env).get_repository(reponame)
     try:
         changeset = repos.get_changeset(rev)
         message = changeset.message
         rev = changeset.rev
         resource = repos.resource
     except Exception:
         message = content
         resource = Resource('repository', reponame)
     if formatter.context.resource.realm == 'ticket':
         ticket_re = CommitTicketUpdater.ticket_re
         if not any(int(tkt_id) == int(formatter.context.resource.id)
                    for tkt_id in ticket_re.findall(message)):
             return tag.p(_("(The changeset message doesn't reference this "
                            "ticket)"), class_='hint')
     if ChangesetModule(self.env).wiki_format_messages:
         return tag.div(format_to_html(self.env,
             formatter.context.child('changeset', rev, parent=resource),
             message, escape_newlines=True), class_='message')
     else:
         return tag.pre(message, class_='message')
开发者ID:aroth-arsoft,项目名称:arsoft-trac-commitupdater,代码行数:25,代码来源:commit_updater.py


示例13: _process_browser_view

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)
开发者ID:klas-genestack,项目名称:github-trac,代码行数:25,代码来源:github.py


示例14: from_comment

    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)
开发者ID:Automattic,项目名称:trac-code-comments-plugin,代码行数:34,代码来源:subscription.py


示例15: _do_seed

    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)
开发者ID:trainormg,项目名称:trac-code-comments-plugin,代码行数:26,代码来源:subscription.py


示例16: add_repository

    def add_repository(self, name):
        """Add a repository."""
        dir = os.path.join(self.parentpath, name)
        if not os.path.isabs(dir):
            raise TracError(_("The repository directory must be absolute"))
        trunk = os.path.join(dir, 'trunk')
        branches = os.path.join(dir, 'branches')
        tags = os.path.join(dir, 'tags')
        command = '"%(svnadmin)s" create "%(dir)s"; "%(svn)s" mkdir --parents -q -m "Created Folders" "file://%(trunk)s" "file://%(branches)s" "file://%(tags)s"' % {
            'svnadmin': self.admin,
            'dir': dir,
            'svn': self.client,
            'trunk': trunk,
            'branches': branches,
            'tags': tags
        }
        process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        (result, error) = process.communicate()
        if error is not None and error != "":
            if error.find('E165002') > -1:
                raise TracError(_('The repository "%(name)s" already exists.', name=name))
            elif error.find('E000002') > -1 or error.find('E000013') > -1:
                raise TracError(_("Can't create the repository '%(name)s.' "
                                  "Make sure the parent directory '%(parentpath)s' exists "
                                  "and the web server has write permissions for it.", name=name, parentpath=self.parentpath))
            else:
                raise TracError(error)
        if self.hookspath and os.path.exists(self.hookspath):
	        hooksdir = os.path.join(dir, 'hooks/')
	        files = os.listdir(self.hookspath)
	        files = [self.hookspath + '/' + filename for filename in files]
	        for file in files:
	        	shutil.copy2(file, hooksdir)
        rm = RepositoryManager(self.env)
        rm.reload_repositories()
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:35,代码来源:api.py


示例17: for_request

    def for_request(cls, env, req, create=False):
        """
        Return a **single** subscription for a HTTP request.
        """
        reponame = req.args.get('reponame')
        rm = RepositoryManager(env)
        repos = rm.get_repository(reponame)

        path = req.args.get('path') or ''
        rev = req.args.get('rev') or repos.youngest_rev

        dict_ = {
            'user': req.authname,
            'type': req.args.get('realm'),
            'path': '',
            'rev': '',
            'repos': '',
        }

        if dict_['type'] == 'attachment':
            dict_['path'] = path

        if dict_['type'] == 'changeset':
            dict_['rev'] = path[1:]
            dict_['repos'] = repos.reponame

        if dict_['type'] == 'browser':
            if len(path) == 0:
                dict_['path'] = '/'
            else:
                dict_['path'] = path[1:]
            dict_['rev'] = rev
            dict_['repos'] = repos.reponame

        return cls._from_dict(env, dict_, create=create)
开发者ID:nuwainfo,项目名称:trac-code-comments-plugin,代码行数:35,代码来源:subscription.py


示例18: __init__

 def __init__(self):
     # Retrieve info for all repositories associated with this project
     self.authz_file = self.config.get('trac', 'authz_file')
     rm = RepositoryManager(self.env)
     all_repos = rm.get_all_repositories()
     for (reponame, info) in all_repos.iteritems():
         self.project_repos.append(reponame)
     self.env.log.debug("SvnAuthzAdminPlugin: project_repos: '%s'" % self.project_repos)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:8,代码来源:admin_ui.py


示例19: render_admin_panel

    def render_admin_panel(self, req, cat, page, path_info):
        req.perm.require('SVNVERIFY_REPORT')
        
        rm = RepositoryManager(self.env)
        all_repos = rm.get_all_repositories()
        db = self.env.get_read_db()
        cursor = db.cursor()
        
        if path_info:
            # detailed
            reponame = not is_default(path_info) and path_info or ''
            info = all_repos.get(reponame)
            if info is None:
                raise TracError(_("Repository '%(repo)s' not found",
                                  repo=path_info))

            cursor.execute("SELECT type, time, result, log "
                           "FROM svnverify_log WHERE repository_id = %s "
                           "ORDER BY time DESC LIMIT 1",
                           (info['id'],))
            row = cursor.fetchone()
            if row:
                info['check_type'] = row[0]
                info['time_checked'] = format_datetime(from_utimestamp(row[1]))
                info['pretty_status'] = int(row[2]) == 0 and "OK" or "Warning"
                info['status'] = row[2]
                info['log'] = row[3]
            info['prettydir'] = breakable_path(info['dir'])
            if info['name'] == '':
                info['name'] = "(default)"
            return 'svnverify.html', {"info": info}
        else:
            repositories = {}
            for reponame, info in all_repos.iteritems():
                if info.get('type',rm.repository_type) == "svn" or (rm.repository_type == 'svn' and info.get('type') == ''):
                    info['prettydir'] = breakable_path(info['dir'])
                    try:
                        r = RepositoryManager(self.env).get_repository(reponame)
                        info['rev'] = r.get_youngest_rev()
                        info['display_rev'] = r.display_rev(info['rev'])
                    except:
                        pass
                    cursor.execute("SELECT type, time, result "
                                   "FROM svnverify_log "
                                   "WHERE repository_id = %s "
                                   "ORDER BY time DESC LIMIT 1",
                                   (info['id'],))
                    row = cursor.fetchone()
                    if row:
                        info['check_type'] = row[0]
                        info['time_checked'] = format_datetime(from_utimestamp(row[1]))
                        info['pretty_status'] = int(row[2]) == 0 and "OK" or "Warning"
                        info['status'] = row[2]

                    repositories[reponame] = info

            add_stylesheet(req, 'svnverify/css/svnverify.css')
            return 'svnverifylist.html', {"repositories": repositories}
开发者ID:CGI-define-and-primeportal,项目名称:trac-plugin-svnverify,代码行数:58,代码来源:web_ui.py


示例20: _do_list

 def _do_list(self):
     rm = RepositoryManager(self.env)
     values = []
     for (reponame, info) in sorted(rm.get_all_repositories().iteritems()):
         alias = ""
         if "alias" in info:
             alias = info["alias"] or "(default)"
         values.append((reponame or "(default)", info.get("type", ""), alias, info.get("dir", "")))
     print_table(values, [_("Name"), _("Type"), _("Alias"), _("Directory")])
开发者ID:moreati,项目名称:trac-gitsvn,代码行数:9,代码来源:admin.py



注:本文中的trac.versioncontrol.RepositoryManager类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python api.RepositoryManager类代码示例发布时间:2022-05-27
下一篇:
Python translation.tag_函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap