~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/add.py

  • Committer: Patch Queue Manager
  • Date: 2011-12-19 17:14:34 UTC
  • mfrom: (6378.1.5 config-si-unit)
  • Revision ID: pqm@pqm.ubuntu.com-20111219171434-i0b4ir0invs9il2v
(vila) Migrate add.maximum_file_size configuration option. (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

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