Changeset 494 in tailor


Ignore:
Timestamp:
08/05/05 02:38:11 (8 years ago)
Author:
lele@…
Hash name:
20050805003811-97f81-1f41174ab3613c3f047128c8281b48f4d3cb9106
Message:

Old configuration definitively gone
Now, invoking tailor in the old way, ie without --configfile but with
--verbose, it emits an equivalent configuration template that you can
redirect to a file. It does perform the action only with --debug.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vcpx/tailor.py

    r493 r494  
    273273    if options.interactive: 
    274274        interactive(options, args) 
    275     elif options.configfile: 
     275    else: 
    276276        defaults = {} 
    277277        for k,v in options.__dict__.items(): 
    278             defaults[k.replace('_', '-')] = v 
    279  
    280         config = Config(open(options.configfile), defaults) 
    281  
    282         if not args: 
    283             args = config.projects() 
    284  
    285         for projname in args: 
    286             project = config[projname] 
    287             tailorizer = Tailorizer(project) 
    288             tailorizer(options) 
    289     else: 
    290         # Good (?) old way 
    291  
    292         config = None 
    293  
    294         base = getcwd() 
    295  
    296         if len(args) == 0: 
    297             args.append(base) 
    298  
    299         while args: 
    300             chdir(base) 
    301  
    302             proj = args.pop(0) 
    303             root = abspath(proj) 
    304  
    305             if options.bootstrap: 
    306                 if exists(join(root, STATUS_FILENAME)): 
    307                     raise ExistingProjectError( 
    308                         "Project %r cannot be bootstrapped twice" % proj) 
    309  
    310                 if not options.source_repository: 
    311                     raise InvocationError('Need a repository to bootstrap %r' % 
    312                                           proj) 
     278            if k not in ['interactive', 'bootstrap', 'configfile']: 
     279                defaults[k.replace('_', '-')] = v 
     280 
     281        if options.configfile: 
     282            config = Config(open(options.configfile), defaults) 
     283 
     284            if not args: 
     285                args = config.projects() 
     286 
     287            for projname in args: 
     288                project = config[projname] 
     289                tailorizer = Tailorizer(project) 
     290                tailorizer(options) 
     291        else: 
     292            config = Config(None, defaults) 
     293 
     294            config.add_section('project') 
     295            source = options.source_kind + ':source' 
     296            config.set('project', 'source', source) 
     297            target = options.target_kind + ':target' 
     298            config.set('project', 'target', target) 
     299            config.set('project', 'root', getcwd()) 
     300            config.set('project', 'subdir', options.subdir or '.') 
     301            config.set('project', 'state-file', 'tailor.state') 
     302            config.set('project', 'start-revision', options.start_revision) 
     303 
     304            config.add_section(source) 
     305            if options.bootstrap and not options.source_repository: 
     306                raise InvocationError('Need a source repository to bootstrap') 
     307 
     308            config.set(source, 'repository', options.source_repository) 
     309            if options.source_module: 
     310                config.set(source, 'module', options.source_module) 
     311 
     312            config.add_section(target) 
     313            if options.target_repository: 
     314                config.set(target, 'repository', options.target_repository) 
     315            if options.target_module: 
     316                config.set(target, 'module', options.target_module) 
     317 
     318            if options.verbose: 
     319                import sys 
     320 
     321                sys.stderr.write("You should put the following configuration " 
     322                                 "in some file, adjust it as needed\n" 
     323                                 "and use --configfile option with that " 
     324                                 "file as argument:\n") 
     325                config.write(sys.stdout) 
     326 
     327            if not options.debug: 
     328                project = config['project'] 
     329                tailorizer = Tailorizer(project) 
     330                tailorizer(options) 
    313331            else: 
    314                 if not exists(proj): 
    315                     raise UnknownProjectError("Project %r does not exist" % 
    316                                               proj) 
    317  
    318                 if not exists(join(root, STATUS_FILENAME)): 
    319                     raise UnknownProjectError( 
    320                         "%r is not a tailorized project" % proj) 
    321  
    322             tailored = TailorizedProject(root, options.verbose, config) 
    323  
    324             if options.bootstrap: 
    325                 tailored.bootstrap(options.source_kind, options.target_kind, 
    326                                    options.source_repository, 
    327                                    options.source_module, 
    328                                    options.revision, 
    329                                    options.target_repository, 
    330                                    options.target_module, 
    331                                    options.subdir) 
    332             elif options.update: 
    333                 tailored.update(options.single_commit, 
    334                                 options.concatenate_logs) 
     332                sys.stderr.write("Operation not performed, given --debug\n") 
Note: See TracChangeset for help on using the changeset viewer.