当前位置: 首页>>代码示例>>Python>>正文


Python versioncontrol.RepositoryManager类代码示例

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


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


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