• Xavier Thompson's avatar
    [feat] Reimplement the extends algorithm · cd27772e
    Xavier Thompson authored
    The new algorithm avoids fetching the same extended file more than once
    and correctly handles overriding values and += and -=:
    
    The new algorithm starts as if there was a buildout file containing
    
    ```
    [buildout]
    extends =
      user/defaults.cfg # if it exists
      buildout.cfg # if it exists
      command_line_extends.cfg # if passed on the command line
    ```
    
    The files are then fetched in depth-first-search postorder and fetching
    child nodes in the order given by the extends directive, ignoring files
    that have already been fetched.
    
    The buildout dicts are then collected in order, and this linearisation
    is then merged at the end, overriding the first configs collected with
    the later ones. The first dict in the linearisation is not from a file,
    but the dict of buildout's (hardcoded) defaults. This is equivalent to
    acting as though every file that does not extend anything extends these
    defaults.
    
    The first time a file must be downloaded from a url, the linearisation
    is merged with the configs already collected, and the resulting options
    are then used to determine the download options for this download, and
    every subsequent download.
    
    This is a break with buildout's current logic for download options.
    
    By analogy with classes in Python, we are computing a linearisation of
    the class hierarchy to determine the method resolution order (MRO).
    This algorithm is not the same as Python's MRO since Python 2.3 (C3).
    
    It could be good to switch to a C3 linearisation like Python.
    cd27772e
buildout.py 83.6 KB