示例#1
0
    def getTestCases(self, component, req ):

        repository = self.getRepository( component, req )
        authzperm = SubversionAuthorizer( component.env, req.authname) 
        authzperm.assert_permission_for_changeset(repository.youngest_rev)

         
        node = repository.get_node( self.getTestCasePath( component, req ), repository.youngest_rev )
        entries = node.get_entries()
        
        testcases = {}
        
        #let's create the list of testcases...
        for entry in entries :
            match = re.match('testtemplates.xml',  entry.get_name() )
            #we want to parse testcases not the testtemplate file...
            if not match:
                content = entry.get_content().read()
                testcase = TestCase( entry.get_name(), str(content), component )
                testcases[ testcase.getId().encode('ascii', 'ignore').strip() ] =  testcase 
        
        #first let's do some validation on the testcases...
        components = self.getComponents( component, req )
        currentTestcase = None
        try:
            for key, value in testcases.iteritems():
                currentTestcase = value #incase we do toss an exception I'll want some information from this testcase
                components.index( value.getComponent().encode('ascii', 'ignore').strip() ) #this will toss an exception if the component in the testcase doesn't exist in the trac project
        except Exception, ex:
            req.hdf['testcase.run.errormessage'] = "The component :" + currentTestcase.getComponent() + " in the testcase : " + currentTestcase.getId() + " does not exist in the trac project " 
            component.env.log.debug( "Error validating testcases " + repr(ex) )
            return None
示例#2
0
    def process_request(self, req):
        req.perm.assert_permission('CHANGESET_VIEW')

        rev = req.args.get('rev')
        repos = self.env.get_repository(req.authname)
        authzperm = SubversionAuthorizer(self.env, req.authname)
        authzperm.assert_permission_for_changeset(rev)

        diff_options = get_diff_options(req)
        if req.args.has_key('update'):
            req.redirect(self.env.href.changeset(rev))

        chgset = repos.get_changeset(rev)
        req.check_modified(chgset.date,
                           diff_options[0] + ''.join(diff_options[1]))

        format = req.args.get('format')
        if format == 'diff':
            self._render_diff(req, repos, chgset, diff_options)
            return
        elif format == 'zip':
            self._render_zip(req, repos, chgset)
            return

        self._render_html(req, repos, chgset, diff_options)
        add_link(req, 'alternate', '?format=diff', 'Unified Diff',
                 'text/plain', 'diff')
        add_link(req, 'alternate', '?format=zip', 'Zip Archive',
                 'application/zip', 'zip')
        add_stylesheet(req, 'common/css/changeset.css')
        add_stylesheet(req, 'common/css/diff.css')
        add_stylesheet(req, 'common/css/code.css')
        return 'changeset.cs', None
示例#3
0
    def get_timeline_events(self, req, start, stop, filters):
        if 'changeset' in filters:
            format = req.args.get('format')
            show_files = int(
                self.config.get('timeline', 'changeset_show_files'))
            db = self.env.get_db_cnx()
            repos = self.env.get_repository()
            authzperm = SubversionAuthorizer(self.env, req.authname)
            rev = repos.youngest_rev
            while rev:
                if not authzperm.has_permission_for_changeset(rev):
                    rev = repos.previous_rev(rev)
                    continue

                chgset = repos.get_changeset(rev)
                if chgset.date < start:
                    return
                if chgset.date < stop:
                    message = chgset.message or '--'
                    if format == 'rss':
                        title = util.Markup('Changeset <em>[%s]</em>: %s',
                                            chgset.rev,
                                            util.shorten_line(message))
                        href = self.env.abs_href.changeset(chgset.rev)
                        message = wiki_to_html(message,
                                               self.env,
                                               req,
                                               db,
                                               absurls=True)
                    else:
                        title = util.Markup('Changeset <em>[%s]</em> by %s',
                                            chgset.rev, chgset.author)
                        href = self.env.href.changeset(chgset.rev)
                        message = wiki_to_oneliner(message,
                                                   self.env,
                                                   db,
                                                   shorten=True)
                    if show_files:
                        files = []
                        for chg in chgset.get_changes():
                            if show_files > 0 and len(files) >= show_files:
                                files.append('...')
                                break
                            files.append('<span class="%s">%s</span>' %
                                         (chg[2], util.escape(chg[0])))
                        message = '<span class="changes">' + ', '.join(files) +\
                                  '</span>: ' + message
                    yield 'changeset', href, title, chgset.date, chgset.author,\
                          util.Markup(message)
                rev = repos.previous_rev(rev)
示例#4
0
 def get_search_results(self, req, query, filters):
     if not 'changeset' in filters:
         return
     authzperm = SubversionAuthorizer(self.env, req.authname)
     db = self.env.get_db_cnx()
     sql, args = query_to_sql(db, query, 'message||author')
     cursor = db.cursor()
     cursor.execute("SELECT rev,time,author,message "
                    "FROM revision WHERE " + sql, args)
     for rev, date, author, log in cursor:
         if not authzperm.has_permission_for_changeset(rev):
             continue
         yield (self.env.href.changeset(rev),
                '[%s]: %s' % (rev, util.shorten_line(log)),
                date, author, shorten_result(log, query.split()))
示例#5
0
    def process_request(self, req, db=None):
        req.perm.assert_permission('CHANGESET_VIEW')

        if not db:
            db = self.env.get_db_cnx()

        # Fetch the standard ticket fields
        cursor = db.cursor()

        ticket_id = req.args.get('ticket_id')
        req.hdf['ticket_id'] = ticket_id

        repos = self.env.get_repository(req.authname)
        authzperm = SubversionAuthorizer(self.env, req.authname)

        diff_options = get_diff_options(req)
        if req.args.has_key('update'):
            req.redirect(self.env.href.setchangeset(ticket_id))

        ticket = Ticket(self.env, ticket_id)

        ticket.setchangesets = self.get_setchangesets(ticket_id, db)

        ticket.values['setchangesets'] = ticket.setchangesets

        ticket.values['changesets'] = ""
        for changeset in ticket.setchangesets:
            ticket.values['changesets'] += str(changeset)

        setchangesets = ticket.setchangesets
        req.hdf['ticket'] = ticket
        req.hdf['dbWarning'] = False

        # get the list of changesets for the ticket_id
        # then loop through and get the actual changesets like the following line
        chgset = []
        self.log.debug('PublishRevert: %s', ticket['ticketaction'])
        for rev in setchangesets:
            authzperm.assert_permission_for_changeset(rev)
            changeset = repos.get_changeset(rev)
            chgset.append(changeset)

        format = req.args.get('format')

        self._render_html(req, ticket, repos, chgset, diff_options)

        return 'setchangeset.cs', None
示例#6
0
    def process_request(self, req, db=None):
        req.perm.assert_permission('CHANGESET_VIEW')

        if not db:
            db = self.env.get_db_cnx()

        # Fetch the standard ticket fields
        cursor = db.cursor()

        ticket_id = req.args.get('ticket_id')
	req.hdf['ticket_id'] = ticket_id

        repos = self.env.get_repository(req.authname)
        authzperm = SubversionAuthorizer(self.env, req.authname)

        diff_options = get_diff_options(req)
        if req.args.has_key('update'):
            req.redirect(self.env.href.setchangeset(ticket_id))

	ticket = Ticket(self.env, ticket_id)

	ticket.setchangesets = self.get_setchangesets(ticket_id,db)

	ticket.values['setchangesets'] = ticket.setchangesets

	ticket.values['changesets'] = ""
	for changeset in ticket.setchangesets:
	    ticket.values['changesets'] +=  str(changeset)
	
	setchangesets = ticket.setchangesets
	req.hdf['ticket'] = ticket
	req.hdf['dbWarning'] = False

	# get the list of changesets for the ticket_id
	# then loop through and get the actual changesets like the following line
	chgset = []
	self.log.debug('PublishRevert: %s', ticket['ticketaction'])
	for rev in setchangesets:
	    authzperm.assert_permission_for_changeset(rev)
	    changeset = repos.get_changeset(rev)
            chgset.append(changeset)

        format = req.args.get('format')

        self._render_html(req, ticket, repos, chgset, diff_options)

        return 'setchangeset.cs', None
示例#7
0
    def process_request(self, req, db=None):
        req.perm.assert_permission('TRAC_ADMIN')

        if not db:
            self.db = self.env.get_db_cnx()

        ticket_id = req.args.get('ticket_id')
	req.hdf['ticket_id'] = ticket_id
	req.hdf['message'] = ''

        repos = self.env.get_repository(req.authname)
        authzperm = SubversionAuthorizer(self.env, req.authname)

        diff_options = get_diff_options(req)
        if req.args.has_key('update'):
            req.redirect(self.env.href.svnpublish(ticket_id))

	ticket = Ticket(self.env, ticket_id)
        chgset = []

	if(ticket['ticketaction'] == "ClonePublish"):
            from publishrevert.setchangeset import SetChangesetModule
  	    setchangeset = SetChangesetModule(self.env)
            setchangesets = setchangeset.get_setchangesets(ticket_id)

	    # get the list of changesets for the ticket_id
	    # then loop through and get the actual changesets like the following line
	    for rev in setchangesets:
	        authzperm.assert_permission_for_changeset(rev)
	        changeset = repos.get_changeset(rev)

	    # now loop through the files in changeset to get all the paths
	    # and for each path, find the current test/prod revision number and save that info
                chgset.append(changeset)

            format = req.args.get('format')
            self._render_html(req, ticket, repos, chgset, diff_options)
	    req.hdf['setchangesets'] = setchangesets
	    ticket['ticketaction'] = 'CloneTest'
	    ticket.save_changes(req.authname, 'published to clone', 0, db)
	    req.hdf['message'] += 'Successfully Published All Files'
            req.hdf['ticket'] = ticket.values
	else:
	    req.hdf['error'] = 'Error: not in correct state to publish'

        return 'setchangeset.cs', None
示例#8
0
    def process_request(self, req, db=None):
        req.perm.assert_permission('TRAC_ADMIN')

        if not db:
            self.db = self.env.get_db_cnx()

        ticket_id = req.args.get('ticket_id')
        req.hdf['ticket_id'] = ticket_id
        req.hdf['message'] = ''

        repos = self.env.get_repository(req.authname)
        authzperm = SubversionAuthorizer(self.env, req.authname)

        diff_options = get_diff_options(req)
        if req.args.has_key('update'):
            req.redirect(self.env.href.svnpublish(ticket_id))

        ticket = Ticket(self.env, ticket_id)
        chgset = []

        if (ticket['ticketaction'] == "ClonePublish"):
            from publishrevert.setchangeset import SetChangesetModule
            setchangeset = SetChangesetModule(self.env)
            setchangesets = setchangeset.get_setchangesets(ticket_id)

            # get the list of changesets for the ticket_id
            # then loop through and get the actual changesets like the following line
            for rev in setchangesets:
                authzperm.assert_permission_for_changeset(rev)
                changeset = repos.get_changeset(rev)

                # now loop through the files in changeset to get all the paths
                # and for each path, find the current test/prod revision number and save that info
                chgset.append(changeset)

            format = req.args.get('format')
            self._render_html(req, ticket, repos, chgset, diff_options)
            req.hdf['setchangesets'] = setchangesets
            ticket['ticketaction'] = 'CloneTest'
            ticket.save_changes(req.authname, 'published to clone', 0, db)
            req.hdf['message'] += 'Successfully Published All Files'
            req.hdf['ticket'] = ticket.values
        else:
            req.hdf['error'] = 'Error: not in correct state to publish'

        return 'setchangeset.cs', None
示例#9
0
    def get_timeline_events(self, req, start, stop, filters):
        if 'changeset' in filters:
            format = req.args.get('format')
            show_files = int(self.config.get('timeline',
                                             'changeset_show_files'))
            db = self.env.get_db_cnx()
            repos = self.env.get_repository()
            authzperm = SubversionAuthorizer(self.env, req.authname)
            rev = repos.youngest_rev
            while rev:
                if not authzperm.has_permission_for_changeset(rev):
                    rev = repos.previous_rev(rev)
                    continue

                chgset = repos.get_changeset(rev)
                if chgset.date < start:
                    return
                if chgset.date < stop:
                    message = chgset.message or '--'
                    if format == 'rss':
                        title = util.Markup('Changeset <em>[%s]</em>: %s',
                                            chgset.rev,
                                            util.shorten_line(message))
                        href = self.env.abs_href.changeset(chgset.rev)
                        message = wiki_to_html(message, self.env, req, db,
                                               absurls=True)
                    else:
                        title = util.Markup('Changeset <em>[%s]</em> by %s',
                                            chgset.rev, chgset.author)
                        href = self.env.href.changeset(chgset.rev)
                        message = wiki_to_oneliner(message, self.env, db,
                                                   shorten=True)
                    if show_files:
                        files = []
                        for chg in chgset.get_changes():
                            if show_files > 0 and len(files) >= show_files:
                                files.append('...')
                                break
                            files.append('<span class="%s">%s</span>'
                                         % (chg[2], util.escape(chg[0])))
                        message = '<span class="changes">' + ', '.join(files) +\
                                  '</span>: ' + message
                    yield 'changeset', href, title, chgset.date, chgset.author,\
                          util.Markup(message)
                rev = repos.previous_rev(rev)
示例#10
0
    def get_auth_groups(self):
        class any_auth_name(object):
            def __requal__():
                return True

        authz = SubversionAuthorizer(self.env, None, any_auth_name())
        if isinstance(authz, RealSubversionAuthorizer):
            return authz.groups
        else:
            return []
示例#11
0
    def get_repository(self, type, dir, authname):
        """Return a `SubversionRepository`.

        The repository is generally wrapped in a `CachedRepository`,
        unless `direct-svn-fs` is the specified type.
        """
        repos = SubversionRepository(dir, None, self.log)
        crepos = CachedRepository(self.env.get_db_cnx(), repos, None, self.log)
        if authname:
            authz = SubversionAuthorizer(self.env, crepos, authname)
            repos.authz = crepos.authz = authz
        return crepos
示例#12
0
    def getTemplates( self, component, req ):
        #templates.xml is stored in the same directory as the testcases
        repository = self.getRepository( component, req )
        authzperm = SubversionAuthorizer( component.env, req.authname) 
        authzperm.assert_permission_for_changeset(repository.youngest_rev)

        node = repository.get_node( self.getTestCasePath( component, req ), repository.youngest_rev )
        entries = node.get_entries()
        
        templates = []
        
        #ok spin through the entries we only care about one called testtemplates.xml
        for entry in entries :
            match = re.match('testtemplates.xml',  entry.get_name() )
            if match:
                content = entry.get_content().read()
                return Templates( str(content), component ) #there should only be one testtemplates.xml file...
            #else:
            #    component.env.log.debug( "didn't care about : " + entry.get_name() )
        
        return None
示例#13
0
    def getTestCases(self, component, req):

        repository = self.getRepository(component, req)
        authzperm = SubversionAuthorizer(component.env, req.authname)
        authzperm.assert_permission_for_changeset(repository.youngest_rev)

        node = repository.get_node(self.getTestCasePath(component, req),
                                   repository.youngest_rev)
        entries = node.get_entries()

        testcases = {}

        #let's create the list of testcases...
        for entry in entries:
            match = re.match('testtemplates.xml', entry.get_name())
            #we want to parse testcases not the testtemplate file...
            if not match:
                content = entry.get_content().read()
                testcase = TestCase(entry.get_name(), str(content), component)
                testcases[testcase.getId().encode('ascii',
                                                  'ignore').strip()] = testcase

        #first let's do some validation on the testcases...
        components = self.getComponents(component, req)
        currentTestcase = None
        try:
            for key, value in testcases.iteritems():
                currentTestcase = value  #incase we do toss an exception I'll want some information from this testcase
                components.index(
                    value.getComponent().encode('ascii', 'ignore').strip()
                )  #this will toss an exception if the component in the testcase doesn't exist in the trac project
        except Exception, ex:
            req.hdf[
                'testcase.run.errormessage'] = "The component :" + currentTestcase.getComponent(
                ) + " in the testcase : " + currentTestcase.getId(
                ) + " does not exist in the trac project "
            component.env.log.debug("Error validating testcases " + repr(ex))
            return None
示例#14
0
    def process_request(self, req):
        req.perm.assert_permission('CHANGESET_VIEW')

        ticket_id = req.args.get('ticket_id')
	req.hdf['ticket_id'] = ticket_id

        repos = self.env.get_repository(req.authname)
        authzperm = SubversionAuthorizer(self.env, req.authname)

        diff_options = get_diff_options(req)
        if req.args.has_key('update'):
            req.redirect(self.env.href.setchangeset(ticket_id))

	ticket = Ticket(self.env, ticket_id)
	setchangesets = ticket.setchangesets

	# get the list of changesets for the ticket_id
	# then loop through and get the actual changesets like the following line
	chgset = []
	for rev in setchangesets:
	    authzperm.assert_permission_for_changeset(rev)
	    changeset = repos.get_changeset(rev)
            chgset.append(changeset)
	    req.check_modified(changeset.date,
                      diff_options[0] + ''.join(diff_options[1]))

        format = req.args.get('format')

        self._render_html(req, ticket, repos, chgset, diff_options)
        add_link(req, 'alternate', '?format=diff', 'Unified Diff',
                 'text/plain', 'diff')
        add_link(req, 'alternate', '?format=zip', 'Zip Archive',
                 'application/zip', 'zip')
        add_stylesheet(req, 'common/css/changeset.css')
        add_stylesheet(req, 'common/css/diff.css')
        add_stylesheet(req, 'common/css/code.css')
        return 'setchangeset.cs', None
示例#15
0
    def getTemplates(self, component, req):
        #templates.xml is stored in the same directory as the testcases
        repository = self.getRepository(component, req)
        authzperm = SubversionAuthorizer(component.env, req.authname)
        authzperm.assert_permission_for_changeset(repository.youngest_rev)

        node = repository.get_node(self.getTestCasePath(component, req),
                                   repository.youngest_rev)
        entries = node.get_entries()

        templates = []

        #ok spin through the entries we only care about one called testtemplates.xml
        for entry in entries:
            match = re.match('testtemplates.xml', entry.get_name())
            if match:
                content = entry.get_content().read()
                return Templates(
                    str(content), component
                )  #there should only be one testtemplates.xml file...
            #else:
            #    component.env.log.debug( "didn't care about : " + entry.get_name() )

        return None
示例#16
0
 def get_repository(self, authname=None):
     """Return the version control repository configured for this
     environment.
     
     The repository is wrapped in a `CachedRepository`.
     
     @param authname: user name for authorization
     """
     from trac.versioncontrol.cache import CachedRepository
     from trac.versioncontrol.svn_authz import SubversionAuthorizer
     from trac.versioncontrol.svn_fs import SubversionRepository
     repos_dir = self.config.get('trac', 'repository_dir')
     if not repos_dir:
         raise EnvironmentError, 'Path to repository not configured'
     authz = None
     if authname:
         authz = SubversionAuthorizer(self, authname)
     repos = SubversionRepository(repos_dir, authz, self.log)
     return CachedRepository(self.get_db_cnx(), repos, authz, self.log)
示例#17
0
 def get_permission_groups(self, username):
     authz = SubversionAuthorizer(self.env, None, username)
     if isinstance(authz, RealSubversionAuthorizer):
         return authz._groups()
     else:
         return []
示例#18
0
 def get_permission_groups(self, username):
     authz = SubversionAuthorizer(self.env, None, username)
     if isinstance(authz, RealSubversionAuthorizer):
         return authz._groups()
     else:
         return []