示例#1
0
    def process_module(self, imodule):

        if imodule.type in ["cvs", "distribution"]:
            tmpdir="branch_tmp_"+str(distributions.my_get_thread_ident())
            shell.rm(tmpdir)

            try:

                if imodule.type == "cvs":
                    imodule.checkout(
                        date = self.source_date,
                        tag = self.source_tag,
                        as = tmpdir)
                else:
                    cvs.Checkout(self.source_tag or imodule.cvs_tag,
                                 "distribution",
                                 imodule.cvs_root,
                                 tmpdir,
                                 self.source_date or imodule.cvs_date)

                cmd='cvs tag %s %s "%s"' %( self.cvs_flags,self.dash_b,  self.tag )
                print "Running: %s (in %s + %s)" % (cmd, os.getcwd(), tmpdir)
                status, output = shell.run(cmd, dir = tmpdir)
                print output
                if status:
                    print "Tagging module %s failed\n" % imodule.id

            except cvs.cvs_error:
                print "Tagging module %s failed\n" % imodule.id
            
            shell.rm(tmpdir)
示例#2
0
    def process_module(self, imodule):

        if imodule.type in ["cvs", "distribution"]:
            revisions=0
                
            tmpdir="diff_tmp_"+str(distributions.my_get_thread_ident())
            shell.rm(tmpdir)

            try:

                if imodule.type == "cvs":
                    imodule.checkout(
                        date = self.source_date,
                        tag = self.source_tag,
                        as = tmpdir)
                else:
                    cvs.Checkout(self.source_tag or imodule.cvs_tag,
                                 "distribution",
                                 imodule.cvs_root,
                                 tmpdir,
                                 self.source_date or imodule.cvs_date)

                tag = "-b"
                try:
                    tag=string.strip(open(os.path.join(tmpdir,"CVS","Tag"),"r").read())

                    ## Fixme: what if the sticky tag is a date??
                    
                    if tag and tag[0] == "T":
                        tag = "-r"+tag[1:]
                    else:
                        tag = "-b"
                            
                except IOError:
                    pass

                cmd='cvs log%s -N %s >cvs-log-temp-file' %( self.date_range,
                                                            tag )
                print "Running: %s (in %s + %s)" % (cmd, os.getcwd(), tmpdir)
                status, output = shell.run(cmd, dir = tmpdir)

                print output

                output=open(os.path.join(tmpdir,"cvs-log-temp-file"),"r").read()

                output=string.replace(output,"\r\n","\n")

                root="UNKNOWN"
                try:
                    root=open(os.path.join(tmpdir,"CVS","Root"),"r").read()
                    root=string.strip(root)
                except IOError:
                    pass

                base_repository="UNKNOWN"
                try:
                    base_repository=open(os.path.join(tmpdir,"CVS","Repository"),"r").read()
                    base_repository=string.strip(base_repository)
                except IOError:
                    pass

                
                viewcvs_base = cvs.GetViewCVSUrl(imodule.cvs_root,
                                                 imodule.cvs_path or
                                                 imodule.name)

                blocks=string.split(output,
                                    "=============================================================================")
                for file in blocks[:-2]:
                    data=string.split(file,"----------------------------\nrevision ")
                    wf=string.split(data[0],"Working file: ",1)[1]
                    wf=string.split(wf,"\n",1)[0]
                    local_name=os.path.join(imodule.name, wf)
                    print " - %s, %d revisions" % (wf, len(data)-1)

                    viewcvs_url=None
                    if viewcvs_base:
                        viewcvs_url=posixpath.join(viewcvs_base,wf)

                    cvs_file=os.path.join(base_repository, wf)
                    for revision in data[1:]:
                        revdata=string.split(revision,";",3)
                        author=string.split(revdata[1])[1]

                        ## Ignore build farm checkins
                        if author in [ "mserver", "drmbuild", "buildq", "codecbuild" ]:
                            continue

                        tmp=string.split(revdata[0])
                        rev=tmp[0]

                        t="%s %s" % (tmp[2],tmp[3])
                        t=time.strptime(t,"%Y/%m/%d %H:%M:%S")
                        t=time.mktime(t)-time.timezone
                        author=string.split(revdata[1])[1]
                        comment=string.split(revdata[3],"\n",1)[1]
                        if string.split(comment,":",1)[0] == "branches":
                            comment=string.split(comment,"\n",1)[1]

                                                    
                        ci=Checkin(author, t, comment)
                        ci.add(File(local_name, rev,
                                    root, cvs_file,
                                    viewcvs_url))

                        self.checkins.append(ci)
                        revisions = revisions + 1
                
                if status:
                    print "Diff module %s failed\n" % imodule.id

            except cvs.cvs_error:
                print "Diff module %s failed\n" % imodule.id

            shell.rm(tmpdir)
            print "%d revisions in %s" % (revisions, imodule.id)