Allura/allura/model/repository.py
def _build(cls, tree):
        '''
          Build the LCD record, presuming that this tree is where it was most
          recently changed.
        '''
        model_cache = getattr(c, 'model_cache', '') or ModelCache()
        path = tree.path().strip('/')
        entries = []
        prev_lcd = None
        prev_lcd_cid = cls._prev_commit_id(tree.commit, path)
        if prev_lcd_cid:
            prev_lcd = model_cache.get(
                cls, {'path': path, 'commit_id': prev_lcd_cid})
        entries = {}
        nodes = set(
            [node.name for node in chain(tree.tree_ids, tree.blob_ids, tree.other_ids)])
        changed = set(
            [node for node in nodes if os.path.join(path, node) in tree.commit.changed_paths])
        unchanged = [os.path.join(path, node) for node in nodes - changed]
        if prev_lcd:
            # get unchanged entries from previously computed LCD
            entries = prev_lcd.by_name
        elif unchanged:
            # no previously computed LCD, so get unchanged entries from SCM
            # (but only ask for the ones that we know we need)
            entries = tree.commit.repo.last_commit_ids(tree.commit, unchanged)
            if entries is None:
                # something strange went wrong; still show the list of files
                # and possibly try again later
                entries = {}
            # paths are fully-qualified; shorten them back to just node names
            entries = {
                os.path.basename(path): commit_id for path, commit_id in entries.iteritems()}
        # update with the nodes changed in this tree's commit
        entries.update({node: tree.commit._id for node in changed})
        # convert to a list of dicts, since mongo doesn't handle arbitrary keys
        # well (i.e., . and $ not allowed)
        entries = [{'name': name, 'commit_id': value}
                   for name, value in entries.iteritems()]
        lcd = cls(
            commit_id=tree.commit._id,
            path=path,
            entries=entries,
        )
        model_cache.set(cls, {'path': path, 'commit_id': tree.commit._id}, lcd)
        return lcd

          Build the LCD record, presuming that this tree is where it was most
          recently changed.
        
Build the LCD record, presuming that this tree is where it was most
recently changed.
Build the LCD record presuming that this tree is where it was most recently changed .
def _build(cls, tree):
        model_cache = getattr(c, 'model_cache', '') or ModelCache()
        path = tree.path().strip('/')
        entries = []
        prev_lcd = None
        prev_lcd_cid = cls._prev_commit_id(tree.commit, path)
        if prev_lcd_cid:
            prev_lcd = model_cache.get(
                cls, {'path': path, 'commit_id': prev_lcd_cid})
        entries = {}
        nodes = set(
            [node.name for node in chain(tree.tree_ids, tree.blob_ids, tree.other_ids)])
        changed = set(
            [node for node in nodes if os.path.join(path, node) in tree.commit.changed_paths])
        unchanged = [os.path.join(path, node) for node in nodes - changed]
        if prev_lcd:
            entries = prev_lcd.by_name
        elif unchanged:
            entries = tree.commit.repo.last_commit_ids(tree.commit, unchanged)
            if entries is None:
                entries = {}
            entries = {
                os.path.basename(path): commit_id for path, commit_id in entries.iteritems()}
        entries.update({node: tree.commit._id for node in changed})
        entries = [{'name': name, 'commit_id': value}
                   for name, value in entries.iteritems()]
        lcd = cls(
            commit_id=tree.commit._id,
            path=path,
            entries=entries,
        )
        model_cache.set(cls, {'path': path, 'commit_id': tree.commit._id}, lcd)
        return lcd
def _build ( cls , tree ) : model_cache = getattr ( c , 'model_cache' , '' ) or ModelCache ( ) path = tree . path ( ) . strip ( '/' ) entries = [ ] prev_lcd = None prev_lcd_cid = cls . _prev_commit_id ( tree . commit , path ) if prev_lcd_cid : prev_lcd = model_cache . get ( cls , { 'path' : path , 'commit_id' : prev_lcd_cid } ) entries = { } nodes = set ( [ node . name for node in chain ( tree . tree_ids , tree . blob_ids , tree . other_ids ) ] ) changed = set ( [ node for node in nodes if os . path . join ( path , node ) in tree . commit . changed_paths ] ) unchanged = [ os . path . join ( path , node ) for node in nodes - changed ] if prev_lcd : entries = prev_lcd . by_name elif unchanged : entries = tree . commit . repo . last_commit_ids ( tree . commit , unchanged ) if entries is None : entries = { } entries = { os . path . basename ( path ) : commit_id for path , commit_id in entries . iteritems ( ) } entries . update ( { node : tree . commit . _id for node in changed } ) entries = [ { 'name' : name , 'commit_id' : value } for name , value in entries . iteritems ( ) ] lcd = cls ( commit_id = tree . commit . _id , path = path , entries = entries , ) model_cache . set ( cls , { 'path' : path , 'commit_id' : tree . commit . _id } , lcd ) return lcd
Build the LCD record, presuming that this tree is where it was most
recently changed.
Build the LCD record presuming that this tree is where it was most recently changed .
'''
          Build the LCD record, presuming that this tree is where it was most
          recently changed.
        ''' # get unchanged entries from previously computed LCD # no previously computed LCD, so get unchanged entries from SCM # (but only ask for the ones that we know we need) # something strange went wrong; still show the list of files # and possibly try again later # paths are fully-qualified; shorten them back to just node names # update with the nodes changed in this tree's commit # convert to a list of dicts, since mongo doesn't handle arbitrary keys # well (i.e., . and $ not allowed)
cls
tree