Beispiel #1
0
    def update_set (cls, data, request, parent=None):
        ident = u'/set/' + data['blip:id']
        record = blip.db.ReleaseSet.get_or_create (ident, u'Set')
        if parent:
            record.parent = parent

        if data.has_key ('name'):
            record.update (name=data['name'])

        #if data.has_key ('links'):
        #    pulse.pulsate.update_links (record, data['links'])

        #if data.has_key ('schedule'):
        #    pulse.pulsate.update_schedule (record, data['schedule'])

        # Sets may contain either other sets or modules, not both
        if data.has_key ('set'):
            rels = []
            for subset in data['set'].keys():
                subrecord = cls.update_set (data['set'][subset], request, parent=record)
        elif (data.has_key ('module')):
            rels = []
            for xml_data in data['module'].values():
                mod_data = {}
                for k in xml_data.keys():
                    if k[:4] == 'scm_':
                        mod_data[str(k)] = xml_data[k]
                checkout = blip.scm.Repository (checkout=False, update=False, **mod_data)
                servername = checkout.server_name
                if servername == None:
                    continue
                if mod_data.get ('scm_branch', '') == '':
                    mod_data['scm_branch'] = checkout.scm_branch
                if mod_data.get ('scm_branch', '') == '':
                    continue
                ident = u'/'.join (['/mod', servername, mod_data['scm_module'], mod_data['scm_branch']])
                branch = blip.db.Branch.get_or_create (ident, u'Module')
                branch.update (mod_data)
                rels.append (blip.db.SetModule.set_related (record, branch))
            record.set_relations (blip.db.SetModule, rels)

        for sweeper in SetSweeper.get_extensions ():
            sweeper.sweep_set (record, data, request)

        return record
Beispiel #2
0
    def sweep_set (cls, record, data, request):
        if not (data.has_key ('jhbuild_scm_type')   and
                data.has_key ('jhbuild_scm_server') and
                data.has_key ('jhbuild_scm_module') and
                data.has_key ('jhbuild_scm_dir')    and
                data.has_key ('jhbuild_scm_file')):
            return False
        repo = blip.scm.Repository (scm_type=data['jhbuild_scm_type'],
                                    scm_server=data['jhbuild_scm_server'],
                                    scm_module=data['jhbuild_scm_module'],
                                    scm_branch=data.get('jhbuild_scm_branch'),
                                    scm_path=data.get('jhbuild_scm_path'),
                                    update=request.get_tool_option ('update_scm', True))
        filename = os.path.join (repo.directory,
                                 data['jhbuild_scm_dir'],
                                 data['jhbuild_scm_file'])

        if not cls.modulesets.has_key (filename):
            cls.modulesets[filename] = ModuleSet (filename)
        moduleset = cls.modulesets[filename]

        packages = []
        if not data.has_key ('jhbuild_metamodule'):
            packages = moduleset.get_metamodule (os.path.basename (filename))
        else:
            modules = data['jhbuild_metamodule']
            if isinstance (modules, basestring):
                modules = [modules]

            for module in modules:
                if not moduleset.has_metamodule (module):
                    continue
                packages += moduleset.get_metamodule (module)

        newpkgs = []
        while len(packages) > 0:
            pkg = packages.pop ()
            if moduleset.has_package (pkg):
                newpkgs.append (pkg)
            elif moduleset.has_metamodule (pkg):
                for npkg in moduleset.get_metamodule (pkg):
                    packages.append (npkg)
        packages = newpkgs

        rels = []
        for pkg in packages:
            # FIXME
            branch = cls.update_branch (moduleset, pkg, request)
            if branch is not None:
                rels.append (blip.db.SetModule.set_related (record, branch))
        record.set_relations (blip.db.SetModule, rels)