/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/add.py

  • Committer: Jelmer Vernooij
  • Date: 2018-06-14 17:59:16 UTC
  • mto: This revision was merged to the branch mainline in revision 7065.
  • Revision ID: jelmer@jelmer.uk-20180614175916-a2e2xh5k533guq1x
Move breezy.plugins.git to breezy.git.

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
 
26
28
    )
27
29
from .i18n import gettext
28
30
 
29
 
 
30
31
class AddAction(object):
31
32
    """A class which defines what action to take when adding a file."""
32
33
 
57
58
            self._to_file.write('adding %s\n' % _quote(path))
58
59
        return None
59
60
 
60
 
    def skip_file(self, tree, path, kind, stat_value=None):
 
61
    def skip_file(self, tree, path, kind, stat_value = None):
61
62
        """Test whether the given file should be skipped or not.
62
 
 
 
63
        
63
64
        The default action never skips. Note this is only called during
64
65
        recursive adds
65
 
 
 
66
        
66
67
        :param tree: The tree we are working in
67
68
        :param path: The path being added
68
69
        :param kind: The kind of object being added.
77
78
 
78
79
    _maxSize = None
79
80
 
80
 
    def skip_file(self, tree, path, kind, stat_value=None):
 
81
    def skip_file(self, tree, path, kind, stat_value = None):
81
82
        if kind != 'file':
82
83
            return False
83
84
        opt_name = 'add.maximum_file_size'
85
86
            config = tree.get_config_stack()
86
87
            self._maxSize = config.get(opt_name)
87
88
        if stat_value is None:
88
 
            file_size = os.path.getsize(path)
 
89
            file_size = os.path.getsize(path);
89
90
        else:
90
 
            file_size = stat_value.st_size
 
91
            file_size = stat_value.st_size;
91
92
        if self._maxSize > 0 and file_size > self._maxSize:
92
93
            ui.ui_factory.show_warning(gettext(
93
94
                "skipping {0} (larger than {1} of {2} bytes)").format(
94
 
                path, opt_name, self._maxSize))
 
95
                path, opt_name,  self._maxSize))
95
96
            return True
96
97
        return False
97
98
 
117
118
            # we aren't doing anything special, so let the default
118
119
            # reporter happen
119
120
            file_id = super(AddFromBaseAction, self).__call__(
120
 
                inv, parent_ie, path, kind)
 
121
                        inv, parent_ie, path, kind)
121
122
        return file_id
122
123
 
123
124
    def _get_base_file_id(self, path, parent_ie):