Changeset 643 in tailor


Ignore:
Timestamp:
08/19/05 22:50:47 (8 years ago)
Author:
lele@…
Hash name:
20050819205047-97f81-2b0f2caee3550be011d1dcb4ec300abca6952c47
Message:

Dropped the interactive session

Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • vcpx/tailor.py

    r642 r643  
    1818from project import Project 
    1919from source import InvocationError 
    20 from session import interactive 
    2120 
    2221class Tailorizer(Project): 
     
    158157 
    159158GENERAL_OPTIONS = [ 
    160     make_option("-i", "--interactive", default=False, action="store_true", 
    161                 help="Start an interactive session."), 
    162159    make_option("-D", "--debug", dest="debug", 
    163160                action="store_true", default=False, 
     
    300297    options, args = parser.parse_args() 
    301298 
    302     if options.interactive: 
    303         interactive(options, args) 
     299    defaults = {} 
     300    for k,v in options.__dict__.items(): 
     301        if k <> 'configfile': 
     302            defaults[k.replace('_', '-')] = str(v) 
     303 
     304    if options.configfile or (len(sys.argv)==2 and len(args)==1): 
     305        # Either we have a --configfile, or there are no options 
     306        # and a single argument (to support shebang style scripts) 
     307 
     308        if not options.configfile: 
     309            options.configfile = sys.argv[1] 
     310            args = None 
     311 
     312        config = Config(open(options.configfile), defaults) 
     313 
     314        if not args: 
     315            args = config.projects() 
     316 
     317        for projname in args: 
     318            tailorizer = Tailorizer(projname, config) 
     319            tailorizer() 
    304320    else: 
    305         defaults = {} 
    306         for k,v in options.__dict__.items(): 
    307             if k not in ['interactive', 'configfile']: 
    308                 defaults[k.replace('_', '-')] = str(v) 
    309  
    310         if options.configfile or (len(sys.argv)==2 and len(args)==1): 
    311             # Either we have a --configfile, or there are no options 
    312             # and a single argument (to support shebang style scripts) 
    313  
    314             if not options.configfile: 
    315                 options.configfile = sys.argv[1] 
    316                 args = None 
    317  
    318             config = Config(open(options.configfile), defaults) 
    319  
    320             if not args: 
    321                 args = config.projects() 
    322  
    323             for projname in args: 
    324                 tailorizer = Tailorizer(projname, config) 
    325                 tailorizer() 
    326         else: 
    327             for omit in ['source-kind', 'target-kind', 
    328                          'source-module', 'target-module', 
    329                          'source-repository', 'target-repository', 
    330                          'start-revision', 'subdir']: 
    331                 if omit in defaults: 
    332                     del defaults[omit] 
    333  
    334             config = Config(None, defaults) 
    335  
    336             config.add_section('project') 
    337             source = options.source_kind + ':source' 
    338             config.set('project', 'source', source) 
    339             target = options.target_kind + ':target' 
    340             config.set('project', 'target', target) 
    341             config.set('project', 'root-directory', getcwd()) 
    342             config.set('project', 'subdir', options.subdir or '.') 
    343             config.set('project', 'state-file', 'tailor.state') 
    344             config.set('project', 'start-revision', options.start_revision) 
    345  
    346             config.add_section(source) 
    347             config.set(source, 'repository', options.source_repository) 
    348             if options.source_module: 
    349                 config.set(source, 'module', options.source_module) 
    350  
    351             config.add_section(target) 
    352             if options.target_repository: 
    353                 config.set(target, 'repository', options.target_repository) 
    354             if options.target_module: 
    355                 config.set(target, 'module', options.target_module) 
    356  
    357             if options.verbose: 
    358                 import sys 
    359  
    360                 sys.stderr.write("You should put the following configuration " 
    361                                  "in some file, adjust it as needed\n" 
    362                                  "and use --configfile option with that " 
    363                                  "file as argument:\n") 
    364                 config.write(sys.stdout) 
    365  
    366             if options.debug: 
    367                 tailorizer = Tailorizer('project', config) 
    368                 tailorizer() 
    369             elif not options.verbose: 
    370                 sys.stderr.write("Operation not performed, try --verbose\n") 
     321        for omit in ['source-kind', 'target-kind', 
     322                     'source-module', 'target-module', 
     323                     'source-repository', 'target-repository', 
     324                     'start-revision', 'subdir']: 
     325            if omit in defaults: 
     326                del defaults[omit] 
     327 
     328        config = Config(None, defaults) 
     329 
     330        config.add_section('project') 
     331        source = options.source_kind + ':source' 
     332        config.set('project', 'source', source) 
     333        target = options.target_kind + ':target' 
     334        config.set('project', 'target', target) 
     335        config.set('project', 'root-directory', getcwd()) 
     336        config.set('project', 'subdir', options.subdir or '.') 
     337        config.set('project', 'state-file', 'tailor.state') 
     338        config.set('project', 'start-revision', options.start_revision) 
     339 
     340        config.add_section(source) 
     341        config.set(source, 'repository', options.source_repository) 
     342        if options.source_module: 
     343            config.set(source, 'module', options.source_module) 
     344 
     345        config.add_section(target) 
     346        if options.target_repository: 
     347            config.set(target, 'repository', options.target_repository) 
     348        if options.target_module: 
     349            config.set(target, 'module', options.target_module) 
     350 
     351        if options.verbose: 
     352            import sys 
     353 
     354            sys.stderr.write("You should put the following configuration " 
     355                             "in some file, adjust it as needed\n" 
     356                             "and use --configfile option with that " 
     357                             "file as argument:\n") 
     358            config.write(sys.stdout) 
     359 
     360        if options.debug: 
     361            tailorizer = Tailorizer('project', config) 
     362            tailorizer() 
     363        elif not options.verbose: 
     364            sys.stderr.write("Operation not performed, try --verbose\n") 
  • README

    r639 r643  
    361361will fetch latest changes from the upstream repository. 
    362362 
    363 Interactive sessions 
    364 -------------------- 
    365  
    366 Tailor offers an alternative way of driving its activity by using an 
    367 interactive session, bringing the configuration more similar to a 
    368 script. 
    369  
    370 Although this is still a work-in-progress, it's quickly becoming my 
    371 preferred usage, as its functionality cover the underlying tailor 
    372 features. 
    373  
    374 For example, this is the script I'm using to test it:: 
    375  
    376     cd /tmp 
    377     state_file tailor.state 
    378     source_kind darcs 
    379     target_kind svn 
    380     source_repository /home/lele/WiP/cvsync 
    381     sub_directory cvsync 
    382     refill_changelogs no 
    383     patch_name_format [%(module)s] Changeset %(revision)s by %(author)s 
    384  
    385 that, as you can see, specifies the context needed by tailor to do its 
    386 work. With the following command line:: 
    387  
    388     $ tailor --verbose --interactive tailor.cmds 
    389     Welcome to the Tailor interactive session: you can issue several commands 
    390     with the usual `readline` facilities. With "help" you'll get a list of 
    391     available commands. 
    392  
    393     Current directory: /tmp 
    394     Current state file: /tmp/tailor.state 
    395     Current source kind: darcs 
    396     Current target kind: svn 
    397     Current source repository: /home/lele/WiP/cvsync 
    398     Sub directory: cvsync 
    399     Refill changelogs: False 
    400     Patch name format: [%(module)s] Changeset %(revision)s by %(author)s 
    401     tailor $ help 
    402      
    403     Documented commands (type help <topic>): 
    404     ======================================== 
    405     EOF                print_executed_commands  state_file 
    406     bootstrap          refill_changelogs        sub_directory 
    407     cd                 remove_first_log_line    target_kind 
    408     current_directory  save                     target_module 
    409     exit               source_kind              target_repository 
    410     logfile            source_module 
    411     patch_name_format  source_repository 
    412  
    413     Undocumented commands: 
    414     ====================== 
    415     help 
    416  
    417     tailor $ help bootstrap 
    418      
    419         Usage: bootstrap [revision] 
    420  
    421         Checkout the initial upstream revision, by default HEAD (or 
    422         specified by argument), then import the subtree into the 
    423         target repository. 
    424  
    425 As another example, consider the following commands:: 
    426  
    427     cd /tmp/wc 
    428     state_file tailor.state 
    429     source_kind cvs 
    430     target_kind darcs 
    431     source_repository :pserver:anonymous@cvs.sourceforge.net:/cvsroot/buildbot 
    432     source_module buildbot 
    433     refill_changelogs false 
    434     patch_name_format %(firstlogline)s 
    435     print_executed_commands true 
    436     bootstrap 2004/01/01 20:05:24 
    437     update ask 
    438  
    439 Assuming ``/tmp/wc`` exists, executing them will first bootstrap a new 
    440 darcs repository with a snapshot at the given date of the upstream 
    441 sources, then will proceed with the update, asking confirmation about 
    442 any single changeset:: 
    443  
    444     ... 
    445     Collected 586 upstream changesets 
    446     Changeset 2004-01-07 00:42:07 by warner: 
    447     * buildbot/changes/mail.py (parseFreshCVSMail): .... 
    448     * test/test_mailparse.py (Test1.testMsg9): test for same 
    449  
    450     Apply [Y/n/v/h/q]? h 
    451     y: yes, apply it and keep going 
    452     n: no, skip the current changeset 
    453     v: view more detailed information 
    454     q: do not apply the current changeset and stop iterating 
    455  
    456     Apply [Y/n/v/h/q]? v 
    457     Revision: 2004-01-07 00:42:07 by warner 
    458     Date: 2004-01-07 00:42:07 
    459     Author: warner 
    460     Modified: ChangeLog,buildbot/changes/mail.py,test/test_mailparse.py 
    461     Added: test/mail/msg9 
    462     Log: * buildbot/changes/mail.py (parseFreshCVSMail): ... 
    463     * test/test_mailparse.py (Test1.testMsg9): test for same 
    464      
    465     Apply [Y/n/v/h/q]? 
    466  
    467363         
    468364Further help 
Note: See TracChangeset for help on using the changeset viewer.