示例#1
0
文件: cvsdb.py 项目: viewvc/viewvc
    def AddCommit(self, commit):
        ci_when = dbi.DateTimeFromTicks(commit.GetTime() or 0.0)
        ci_type = commit.GetTypeString()
        who_id = self.GetAuthorID(commit.GetAuthor())
        repository_id = self.GetRepositoryID(commit.GetRepository())
        directory_id = self.GetDirectoryID(commit.GetDirectory())
        file_id = self.GetFileID(commit.GetFile())
        revision = commit.GetRevision()
        sticky_tag = "NULL"
        branch_id = self.GetBranchID(commit.GetBranch())
        plus_count = commit.GetPlusCount() or "0"
        minus_count = commit.GetMinusCount() or "0"
        description_id = self.GetDescriptionID(commit.GetDescription())

        sql = "REPLACE INTO %s" % (self.GetCommitsTable())
        sql += (" (type,ci_when,whoid,repositoryid,dirid,fileid,revision,"
                "stickytag,branchid,addedlines,removedlines,descid)"
                " VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)")
        sql_args = (
            ci_type,
            ci_when,
            who_id,
            repository_id,
            directory_id,
            file_id,
            revision,
            sticky_tag,
            branch_id,
            plus_count,
            minus_count,
            description_id,
        )

        cursor = self.db.cursor()
        try:
            cursor.execute(sql, sql_args)
        except Exception as e:
            raise Exception("Error adding commit: '%s'\n"
                            "Values were:\n"
                            "\ttype     = %s\n"
                            "\tci_when    = %s\n"
                            "\twhoid    = %s\n"
                            "\trepositoryid = %s\n"
                            "\tdirid    = %s\n"
                            "\tfileid     = %s\n"
                            "\trevision   = %s\n"
                            "\tstickytag  = %s\n"
                            "\tbranchid   = %s\n"
                            "\taddedlines   = %s\n"
                            "\tremovedlines = %s\n"
                            "\tdescid     = %s\n" % ((str(e), ) + sql_args))
示例#2
0
    def AddCommit(self, commit):
        ci_when = dbi.DateTimeFromTicks(commit.GetTime())
        ci_type = commit.GetTypeString()
        who_id = self.GetAuthorID(commit.GetAuthor())
        repository_id = self.GetRepositoryID(commit.GetRepository())
        directory_id = self.GetDirectoryID(commit.GetDirectory())
        file_id = self.GetFileID(commit.GetFile())
        revision = commit.GetRevision()
        sticky_tag = "NULL"
        branch_id = self.GetBranchID(commit.GetBranch())
        plus_count = commit.GetPlusCount()
        minus_count = commit.GetMinusCount()
        description_id = self.GetDescriptionID(commit.GetDescription())

        sql = "REPLACE INTO checkins"\
              "  (type,ci_when,whoid,repositoryid,dirid,fileid,revision,"\
              "   stickytag,branchid,addedlines,removedlines,descid)"\
              "VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        sql_args = (ci_type, ci_when, who_id, repository_id,
                    directory_id, file_id, revision, sticky_tag, branch_id,
                    plus_count, minus_count, description_id)

        cursor = self.db.cursor()
        cursor.execute(sql, sql_args)
示例#3
0
 def SetToDateDaysAgo(self, days_ago):
     ticks = time.time() - (86400 * days_ago)
     self.to_date = dbi.DateTimeFromTicks(ticks)
示例#4
0
 def SetFromDateHoursAgo(self, hours_ago):
     ticks = time.time() - (3600 * hours_ago)
     self.from_date = dbi.DateTimeFromTicks(ticks)
示例#5
0
 def SetToDateObject(self, ticks):
     self.to_date = dbi.DateTimeFromTicks(ticks)
示例#6
0
 def SetFromDateObject(self, ticks):
     self.from_date = dbi.DateTimeFromTicks(ticks)