~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/add.py

  • Committer: Martin Packman
  • Date: 2012-01-05 09:50:04 UTC
  • mfrom: (6424 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6426.
  • Revision ID: martin.packman@canonical.com-20120105095004-mia9xb7y0efmto0v
Merge bzr.dev to resolve conflicts in bzrlib.builtins

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Helper functions for adding files to working trees."""
18
18
 
 
19
from __future__ import absolute_import
 
20
 
19
21
import sys
20
22
import os
21
23
 
23
25
    osutils,
24
26
    ui, 
25
27
    )
26
 
 
 
28
from bzrlib.i18n import gettext
27
29
 
28
30
class AddAction(object):
29
31
    """A class which defines what action to take when adding a file."""
73
75
class AddWithSkipLargeAction(AddAction):
74
76
    """A class that can decide to skip a file if it's considered too large"""
75
77
 
76
 
    # default 20 MB
77
 
    _DEFAULT_MAX_FILE_SIZE = 20000000
78
 
    _optionName = 'add.maximum_file_size'
79
78
    _maxSize = None
80
79
 
81
80
    def skip_file(self, tree, path, kind, stat_value = None):
82
81
        if kind != 'file':
83
 
            return False            
 
82
            return False
 
83
        opt_name = 'add.maximum_file_size'
84
84
        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)
 
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)
89
89
        if stat_value is None:
90
90
            file_size = os.path.getsize(path);
91
91
        else:
92
92
            file_size = stat_value.st_size;
93
93
        if self._maxSize > 0 and file_size > self._maxSize:
94
 
            ui.ui_factory.show_warning(
95
 
                "skipping %s (larger than %s of %d bytes)" % 
96
 
                (path, self._optionName,  self._maxSize))
 
94
            ui.ui_factory.show_warning(gettext(
 
95
                "skipping {0} (larger than {1} of {2} bytes)").format(
 
96
                path, opt_name,  self._maxSize))
97
97
            return True
98
98
        return False
99
99