Changeset 3421

Show
Ignore:
Timestamp:
03/26/08 14:59:37 (5 months ago)
Author:
coderanger
Message:

Better solution for sorting.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tracforgeplugin/0.11/tracforge/admin/model.py

    r3419 r3421  
    296296        steps = TracForgeAdminSystem(self.env).get_project_setup_participants() 
    297297         
     298        all_provides = set() 
     299        for action, args in self: 
     300            all_provides |= set(steps[action].get('provides', ())) 
     301         
     302        effective_depends = {} 
     303        for action, args in self: 
     304            # All real deps are always used 
     305            effective_depends.setdefault(action, []).extend(steps[action].get('depends', ())) 
     306            for tag in steps[action].get('optional_depends', ()): 
     307                # Any optional dep that is provided by something else is used 
     308                if tag in all_provides: 
     309                    effective_depends[action].append(tag) 
     310         
    298311        old = set([action for action, args in self]) 
    299312        new = [] 
    300313        tags = set() 
    301         for i, key in itertools.izip(xrange(len(self)*2), itertools.cycle(('depends', 'optional_depends'))): 
     314        for i in xrange(len(self)): 
    302315            for action in old: 
    303                 self.env.log.debug('TracForge: %s %s %s %s %s %s', i, key, action, old, new, tags) 
    304                 if all([tag in tags for tag in steps[action].get(key, [])]): 
    305                     if key == 'depends' and 'optional_depends' in steps[action]: 
    306                         continue 
     316                self.env.log.debug('TracForge: %s %s %s %s %s', i, action, old, new, tags) 
     317                if all([tag in tags for tag in effective_depends[action]]): 
    307318                    new.append(action) 
    308319                    tags |= set(steps[action].get('provides', []))