示例#1
0
文件: review.py 项目: Tigge/critic
    def __init__(self, db, review):
        import gitutils
        from dbutils import User

        self.__old_head_map = {}
        self.__new_head_map = {}

        cursor = db.cursor()
        cursor.execute("""SELECT old_head, new_head, old_upstream, new_upstream, uid
                            FROM reviewrebases
                           WHERE review=%s
                             AND new_head IS NOT NULL""",
                       (review.id,))

        for old_head_id, new_head_id, old_upstream_id, new_upstream_id, user_id in cursor:
            old_head = gitutils.Commit.fromId(db, review.repository, old_head_id)
            new_head = gitutils.Commit.fromId(db, review.repository, new_head_id)

            if old_upstream_id is not None and new_upstream_id is not None:
                old_upstream = gitutils.Commit.fromId(db, review.repository, old_upstream_id)
                new_upstream = gitutils.Commit.fromId(db, review.repository, new_upstream_id)
            else:
                old_upstream = new_upstream = None

            user = User.fromId(db, user_id)
            rebase = ReviewRebase(review, old_head, new_head, old_upstream, new_upstream, user)

            self.append(rebase)
            self.__old_head_map[old_head] = rebase
            self.__new_head_map[new_head] = rebase
示例#2
0
文件: review.py 项目: ryfow/critic
    def getRecipients(self, db):
        from dbutils import User

        cursor = db.cursor()
        cursor.execute("SELECT uid, include FROM reviewrecipientfilters WHERE review=%s", (self.id,))

        default_include = True
        included = set(owner.id for owner in self.owners)
        excluded = set()

        for uid, include in cursor:
            if uid is None:
                default_include = include
            elif include:
                included.add(uid)
            elif uid not in self.owners:
                excluded.add(uid)

        cursor.execute("SELECT uid FROM reviewusers WHERE review=%s", (self.id,))

        recipients = []
        for (user_id,) in cursor:
            if user_id in excluded:
                continue
            elif user_id not in included and not default_include:
                continue

            user = User.fromId(db, user_id)
            if user.status != "retired":
                recipients.append(user)

        return recipients
示例#3
0
    def getRecipients(self, db):
        from dbutils import User

        cursor = db.cursor()
        cursor.execute(
            "SELECT uid, include FROM reviewrecipientfilters WHERE review=%s",
            (self.id, ))

        default_include = True
        included = set(owner.id for owner in self.owners)
        excluded = set()

        for uid, include in cursor:
            if uid is None:
                default_include = include
            elif include:
                included.add(uid)
            elif uid not in self.owners:
                excluded.add(uid)

        cursor.execute("SELECT uid FROM reviewusers WHERE review=%s",
                       (self.id, ))

        recipients = []
        for (user_id, ) in cursor:
            if user_id in excluded:
                continue
            elif user_id not in included and not default_include:
                continue

            user = User.fromId(db, user_id)
            if user.status != "retired":
                recipients.append(user)

        return recipients
示例#4
0
    def __init__(self, db, review):
        import gitutils
        from dbutils import User

        self.__old_head_map = {}
        self.__new_head_map = {}

        cursor = db.cursor()
        cursor.execute("""SELECT old_head, new_head, old_upstream, new_upstream, uid
                            FROM reviewrebases
                           WHERE review=%s
                             AND new_head IS NOT NULL""",
                       (review.id,))

        for old_head_id, new_head_id, old_upstream_id, new_upstream_id, user_id in cursor:
            old_head = gitutils.Commit.fromId(db, review.repository, old_head_id)
            new_head = gitutils.Commit.fromId(db, review.repository, new_head_id)

            if old_upstream_id is not None and new_upstream_id is not None:
                old_upstream = gitutils.Commit.fromId(db, review.repository, old_upstream_id)
                new_upstream = gitutils.Commit.fromId(db, review.repository, new_upstream_id)
            else:
                old_upstream = new_upstream = None

            user = User.fromId(db, user_id)
            rebase = ReviewRebase(review, old_head, new_head, old_upstream, new_upstream, user)

            self.append(rebase)
            self.__old_head_map[old_head] = rebase
            self.__new_head_map[new_head] = rebase

        if review.performed_rebase:
            self.__old_head_map[review.performed_rebase.old_head] = review.performed_rebase
            self.__new_head_map[review.performed_rebase.new_head] = review.performed_rebase
示例#5
0
文件: review.py 项目: jensl/critic
    def __init__(self, db, review):
        import gitutils
        from dbutils import User

        self.__old_head_map = {}
        self.__new_head_map = {}

        cursor = db.cursor()
        cursor.execute("""SELECT old_head, new_head, old_upstream, new_upstream, uid,
                                 equivalent_merge, replayed_rebase
                            FROM reviewrebases
                           WHERE review=%s
                             AND new_head IS NOT NULL""",
                       (review.id,))

        for (old_head_id, new_head_id, old_upstream_id, new_upstream_id, user_id,
             equivalent_merge_id, replayed_rebase_id) in cursor:
            old_head = gitutils.Commit.fromId(db, review.repository, old_head_id)
            new_head = gitutils.Commit.fromId(db, review.repository, new_head_id)

            if old_upstream_id is not None and new_upstream_id is not None:
                old_upstream = gitutils.Commit.fromId(db, review.repository, old_upstream_id)
                new_upstream = gitutils.Commit.fromId(db, review.repository, new_upstream_id)
            else:
                old_upstream = new_upstream = None

            if equivalent_merge_id:
                equivalent_merge = gitutils.Commit.fromId(db, review.repository, equivalent_merge_id)
            else:
                equivalent_merge = None

            if replayed_rebase_id:
                replayed_rebase = gitutils.Commit.fromId(db, review.repository, replayed_rebase_id)
            else:
                replayed_rebase = None

            user = User.fromId(db, user_id)
            rebase = ReviewRebase(review, old_head, new_head, old_upstream, new_upstream, user,
                                  equivalent_merge, replayed_rebase)

            self.append(rebase)
            self.__old_head_map[old_head] = rebase
            self.__new_head_map[new_head] = rebase

            if equivalent_merge:
                self.__old_head_map[equivalent_merge] = rebase

        if review.performed_rebase:
            self.__old_head_map[review.performed_rebase.old_head] = review.performed_rebase
            self.__new_head_map[review.performed_rebase.new_head] = review.performed_rebase