Ejemplo n.º 1
0
 def setUp(self):
     self.env = EnvironmentStub(enable=['trac.*',
                                        'tracopt.ticket.commit_updater.*'])
     self.env.config.set('ticket', 'commit_ticket_update_check_perms', False)
     self.repos = Mock(Repository, 'repos1', {'name': 'repos1', 'id': 1},
                       self.env.log, normalize_rev=lambda rev: 1)
     self.updater = CommitTicketUpdater(self.env)
Ejemplo n.º 2
0
    def _map(self, reponame, changeset):
        # Extract tickets from changeset message.
        ctu = CommitTicketUpdater(self.env)
        tickets = set(ctu._parse_message(changeset.message))
        when = to_utimestamp(changeset.date)
        srev = str(changeset.rev)

        with self.env.db_transaction as db:
            db("DELETE FROM codereviewer_map WHERE repo=%s and changeset=%s",
               (reponame or '', srev))
            if not tickets:
                tickets = ['']  # we still want merges inserted
            for ticket in tickets:
                try:
                    db(
                        """INSERT INTO codereviewer_map
                        (repo,changeset,ticket,time)
                       VALUES (%s,%s,%s,%s)
                       """, (reponame or '', srev, ticket, when))
                except Exception, e:
                    self.log.warning(
                        "Unable to insert changeset "
                        "%s/%s and ticket %s into db: %s", srev, reponame
                        or '', ticket, e)