Changeset 677 in tailor


Ignore:
Timestamp:
08/23/05 14:30:34 (8 years ago)
Author:
lele@…
Hash name:
20050823123034-97f81-e319b9b87edd789f67ab577caa08ace5e009a61d
Message:

Consider only explicit options to override the defaults in the configuration

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vcpx/tailor.py

    r668 r677  
    1414__version__ = '0.9.8' 
    1515 
    16 from optparse import OptionParser, OptionGroup, make_option 
     16from optparse import OptionParser, OptionGroup, Option 
    1717from config import Config 
    1818from project import Project 
     
    158158 
    159159 
     160class RecogOption(Option): 
     161    """ 
     162    Make it possible to recognize an option explicitly given on the 
     163    command line from those simply coming out for their default value. 
     164    """ 
     165 
     166    def process (self, opt, value, values, parser): 
     167        setattr(values, '__seen_' + self.dest, True) 
     168        return Option.process(self, opt, value, values, parser) 
     169 
     170 
    160171GENERAL_OPTIONS = [ 
    161     make_option("-D", "--debug", dest="debug", 
     172    RecogOption("-D", "--debug", dest="debug", 
    162173                action="store_true", default=False, 
    163174                help="Print each executed command. This also keeps " 
    164175                     "temporary files with the upstream logs, that are " 
    165176                     "otherwise removed after use."), 
    166     make_option("-v", "--verbose", dest="verbose", 
     177    RecogOption("-v", "--verbose", dest="verbose", 
    167178                action="store_true", default=False, 
    168179                help="Be verbose, echoing the changelog of each applied " 
    169180                     "changeset to stdout."), 
    170     make_option("--configfile", metavar="CONFNAME", 
     181    RecogOption("--configfile", metavar="CONFNAME", 
    171182                help="Centralized storage of projects info.  With this " 
    172183                     "option and no other arguments tailor will update " 
    173184                     "every project found in the config file."), 
    174     make_option("--encoding", metavar="CHARSET", default=None, 
     185    RecogOption("--encoding", metavar="CHARSET", default=None, 
    175186                help="Force the output encoding to given CHARSET, rather " 
    176187                     "then using the user default settings specified in the " 
     
    179190 
    180191UPDATE_OPTIONS = [ 
    181     make_option("-F", "--patch-name-format", metavar="FORMAT", 
     192    RecogOption("-F", "--patch-name-format", metavar="FORMAT", 
    182193                help="Specify the prototype that will be used " 
    183194                     "to compute the patch name.  The prototype may contain " 
     
    187198                     "setting it to the empty string means that tailor will " 
    188199                     "simply use the original changelog."), 
    189     make_option("-1", "--remove-first-log-line", action="store_true", 
     200    RecogOption("-1", "--remove-first-log-line", action="store_true", 
    190201                default=False, 
    191202                help="Remove the first line of the upstream changelog. This " 
     
    193204                     "when using it's 'firstlogline' variable to build the " 
    194205                     "name of the patch."), 
    195     make_option("-N", "--dont-refill-changelogs", action="store_true", 
     206    RecogOption("-N", "--dont-refill-changelogs", action="store_true", 
    196207                default=False, 
    197208                help="Do not refill every changelog, but keep them as is. " 
     
    202213 
    203214BOOTSTRAP_OPTIONS = [ 
    204     make_option("-s", "--source-kind", dest="source_kind", metavar="VC-KIND", 
     215    RecogOption("-s", "--source-kind", dest="source_kind", metavar="VC-KIND", 
    205216                help="Select the backend for the upstream source " 
    206217                     "version control VC-KIND. Default is 'cvs'.", 
    207218                default="cvs"), 
    208     make_option("-t", "--target-kind", dest="target_kind", metavar="VC-KIND", 
     219    RecogOption("-t", "--target-kind", dest="target_kind", metavar="VC-KIND", 
    209220                help="Select VC-KIND as backend for the shadow repository, " 
    210221                     "with 'darcs' as default.", 
    211222                default="darcs"), 
    212     make_option("-R", "--repository", "--source-repository", 
     223    RecogOption("-R", "--repository", "--source-repository", 
    213224                dest="source_repository", metavar="REPOS", 
    214225                help="Specify the upstream repository, from where bootstrap " 
    215226                     "will checkout the module.  REPOS syntax depends on " 
    216227                     "the source version control kind."), 
    217     make_option("-m", "--module", "--source-module", dest="source_module", 
     228    RecogOption("-m", "--module", "--source-module", dest="source_module", 
    218229                metavar="MODULE", 
    219230                help="Specify the module to checkout at bootstrap time. " 
     
    224235                     "target repository, you may want to give it a value with " 
    225236                     "darcs too even if it is otherwise ignored."), 
    226     make_option("-r", "--revision", "--start-revision", dest="start_revision", 
     237    RecogOption("-r", "--revision", "--start-revision", dest="start_revision", 
    227238                metavar="REV", 
    228239                help="Specify the revision bootstrap should checkout.  REV " 
     
    239250                     "'HEAD' means the latest version in all backends.", 
    240251                default="INITIAL"), 
    241     make_option("-T", "--target-repository", 
     252    RecogOption("-T", "--target-repository", 
    242253                dest="target_repository", metavar="REPOS", default=None, 
    243254                help="Specify the target repository, the one that will " 
    244255                     "receive the patches coming from the source one."), 
    245     make_option("-M", "--target-module", dest="target_module", 
     256    RecogOption("-M", "--target-module", dest="target_module", 
    246257                metavar="MODULE", 
    247258                help="Specify the module on the target repository that will " 
    248259                     "actually contain the upstream source tree."), 
    249     make_option("--subdir", metavar="DIR", 
     260    RecogOption("--subdir", metavar="DIR", 
    250261                help="Force the subdirectory where the checkout will happen, " 
    251262                     "by default it's the tail part of the module name."), 
     
    253264 
    254265VC_SPECIFIC_OPTIONS = [ 
    255     make_option("--use-svn-propset", action="store_true", default=False, 
     266    RecogOption("--use-svn-propset", action="store_true", default=False, 
    256267                dest="use_propset", 
    257268                help="Use 'svn propset' to set the real date and author of " 
     
    300311    defaults = {} 
    301312    for k,v in options.__dict__.items(): 
    302         if k <> 'configfile': 
     313        if k.startswith('__'): 
     314            continue 
     315        if k <> 'configfile' and hasattr(options, '__seen_' + k): 
    303316            defaults[k.replace('_', '-')] = str(v) 
    304317 
Note: See TracChangeset for help on using the changeset viewer.