~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/add.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:
73
73
class AddWithSkipLargeAction(AddAction):
74
74
    """A class that can decide to skip a file if it's considered too large"""
75
75
 
76
 
    # default 20 MB
77
 
    _DEFAULT_MAX_FILE_SIZE = 20000000
78
 
    _optionName = 'add.maximum_file_size'
79
76
    _maxSize = None
80
77
 
81
78
    def skip_file(self, tree, path, kind, stat_value = None):
82
79
        if kind != 'file':
83
 
            return False            
 
80
            return False
 
81
        opt_name = 'add.maximum_file_size'
84
82
        if self._maxSize is None:
85
 
            config = tree.branch.get_config()
86
 
            self._maxSize = config.get_user_option_as_int_from_SI(
87
 
                self._optionName,  
88
 
                self._DEFAULT_MAX_FILE_SIZE)
 
83
            # FIXME: We use the branch config as there is no tree config
 
84
            # -- vila 2011-12-16
 
85
            config = tree.branch.get_config_stack()
 
86
            self._maxSize = config.get(opt_name)
89
87
        if stat_value is None:
90
88
            file_size = os.path.getsize(path);
91
89
        else:
92
90
            file_size = stat_value.st_size;
93
91
        if self._maxSize > 0 and file_size > self._maxSize:
94
92
            ui.ui_factory.show_warning(gettext(
95
 
                "skipping {0} (larger than {1} of {2} bytes)").format(
96
 
                path, self._optionName,  self._maxSize))
 
93
                "skipping {0} (larger than {1} ({2} bytes))").format(
 
94
                path, opt_name,  self._maxSize))
97
95
            return True
98
96
        return False
99
97