~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: Vincent Ladeuil
  • Date: 2011-12-16 16:38:33 UTC
  • mto: This revision was merged to the branch mainline in revision 6387.
  • Revision ID: v.ladeuil+lp@free.fr-20111216163833-4igwmwi1dmxbbebw
Migrate add.maximum_file_size to the new config scheme

Show diffs side-by-side

added added

removed removed

Lines of Context:
440
440
            l = [l]
441
441
        return l
442
442
 
 
443
    @deprecated_method(deprecated_in((2, 5, 0)))
443
444
    def get_user_option_as_int_from_SI(self, option_name, default=None):
444
445
        """Get a generic option from a human readable size in SI units, e.g 10MB
445
446
 
2458
2459
_unit_sfxs = dict(K=10**3, M=10**6, G=10**9)
2459
2460
 
2460
2461
def int_SI_from_store(unicode_str):
 
2462
    """Convert a human readable size in SI units, e.g 10MB into an integer.
 
2463
 
 
2464
    Accepted suffixes are K,M,G. It is case-insensitive and may be followed
 
2465
    by a trailing b (i.e. Kb, MB). This is intended to be practical and not
 
2466
    pedantic.
 
2467
 
 
2468
    :return Integer, expanded to its base-10 value if a proper SI unit is 
 
2469
        found, None otherwise.
 
2470
    """
2461
2471
    regexp = "^(\d+)(([" + ''.join(_unit_sfxs) + "])b?)?$"
2462
2472
    p = re.compile(regexp, re.IGNORECASE)
2463
2473
    m = p.match(unicode_str)
2558
2568
List of GPG key patterns which are acceptable for verification.
2559
2569
"""))
2560
2570
option_registry.register(
 
2571
    Option('add.maximum_file_size',
 
2572
           default=u'20MB', from_unicode=int_SI_from_store,
 
2573
           help="""Size above which files should be added manually.
 
2574
 
 
2575
Files below this size are added automatically when using ``bzr add`` without
 
2576
arguments.
 
2577
 
 
2578
A negative value means disable the size check.
 
2579
"""))
 
2580
option_registry.register(
2561
2581
    Option('bzr.workingtree.worth_saving_limit', default=10,
2562
2582
           from_unicode=int_from_store,  invalid='warning',
2563
2583
           help='''\