Changeset 527 in tailor for vcpx/repository.py


Ignore:
Timestamp:
08/09/05 01:36:47 (8 years ago)
Author:
lele@…
Hash name:
20050808233647-97f81-c2b161feb61fde0d387d466b1710dc661e822899
Message:

Big API change, reducing arguments in favour of instance attributes
This is a big and subtle change that brings nothing in term of
functionality but make it a lot easier maintaining and extending
tailor as a whole.

Basically, 'root' and 'subdir' arguments are gone replaced by a
self.basedir, computed from the configuration; instead of 'logger',
the code uses two new methods, log_info() and log_error() on most
objects. Other arguments are derived from the configuration objects
that hang around.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vcpx/repository.py

    r521 r527  
    3535        as ``source-repository`` (or ``target-repository``) in its [DEFAULT] 
    3636        section. 
     37 
     38        If the configuration does not specify a specific ``root-directory`` 
     39        take the one from the project. 
    3740        """ 
    3841 
     
    4548        self.module = config.get(self.name, 'module') or \ 
    4649                      config.get(self.name, '%s-module' % which) 
    47         if not self.module and self.repository: 
    48             self.module = split(self.repository)[1] 
     50        self.rootdir = config.get(self.name, 'root-directory', 
     51                                  self.project.rootdir) 
     52        self.subdir = config.get(self.name, 'subdir', self.project.subdir) 
     53 
     54    def _validateConfiguration(self): 
     55        """ 
     56        Validate the configuration, possibly altering/completing it. 
     57        """ 
     58 
     59    def log_info(self, what): 
     60        """ 
     61        Print some info on the log and, in verbose mode, to stdout as well. 
     62        """ 
     63 
     64        self.project.log_info(what) 
     65 
     66    def log_error(self, what, exc=False): 
     67        """ 
     68        Print an error message, possibly with an exception traceback, 
     69        to the log and to stdout as well. 
     70        """ 
     71 
     72        self.project.log_error(what, exc) 
    4973 
    5074    def workingDir(self): 
     
    5377        repository. 
    5478        """ 
     79 
     80        from source import InvocationError 
     81 
     82        self._validateConfiguration() 
    5583 
    5684        wdname = self.kind.capitalize() + 'WorkingDir' 
     
    6189        except (AttributeError, ImportError): 
    6290            raise InvocationError("Unhandled source VCS kind: " + self.kind) 
    63         return workingdir() 
     91 
     92        return workingdir(self) 
    6493 
    6594 
     
    73102 
    74103 
     104 
    75105class BzrRepository(Repository): 
    76106    METADIR = '.bzr' 
     
    99129        self.CVS_CMD = config.get(self.name, 'cvs-command', self.CVS_CMD) 
    100130 
     131    def _validateConfiguration(self): 
     132        from os.path import split 
     133        from config import ConfigurationError 
     134 
     135 
     136        if not self.module and self.repository: 
     137            self.module = split(self.repository)[1] 
     138 
     139        if not self.module: 
     140            raise ConfigurationError("Must specify a repository and maybe a module also") 
    101141 
    102142class CvspsRepository(CvsRepository): 
     
    148188                                       'svnadmin-command', self.SVNADMIN_CMD) 
    149189        self.use_propset = config.get(self.name, 'use-propset', False) 
     190 
     191    def _validateConfiguration(self): 
     192        if not self.module: 
     193            raise ConfigurationError("Must the path within the " 
     194                                     "Subversion repository") 
     195 
    150196        if not self.module.startswith('/'): 
     197            self.project.log_info("Prepending '/' to module") 
    151198            self.module = '/' + self.module 
    152199 
Note: See TracChangeset for help on using the changeset viewer.