/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 bzrlib/tests/test_smart_add.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
from .. import (
 
17
from cStringIO import StringIO
 
18
 
 
19
from bzrlib import (
18
20
    add,
19
 
    cache_utf8,
 
21
    inventory,
20
22
    osutils,
21
23
    tests,
22
24
    )
23
 
from ..bzr import (
24
 
    inventory,
25
 
    )
26
 
from ..sixish import (
27
 
    BytesIO,
28
 
    )
29
25
 
30
26
 
31
27
class AddCustomIDAction(add.AddAction):
33
29
    def __call__(self, inv, parent_ie, path, kind):
34
30
        # The first part just logs if appropriate
35
31
        # Now generate a custom id
36
 
        file_id = cache_utf8.encode(kind + '-' + path.replace('/', '%'))
 
32
        file_id = osutils.safe_file_id(kind + '-'
 
33
                                       + path.replace('/', '%'),
 
34
                                       warn=False)
37
35
        if self.should_print:
38
36
            self._to_file.write('added %s with id %s\n'
39
37
                                % (path, file_id))
56
54
 
57
55
    def add_helper(self, base_tree, base_path, new_tree, file_list,
58
56
                   should_print=False):
59
 
        to_file = BytesIO()
 
57
        to_file = StringIO()
60
58
        base_tree.lock_read()
61
59
        try:
62
60
            new_tree.lock_write()
155
153
 
156
154
    def run_action(self, output):
157
155
        inv = inventory.Inventory()
158
 
        stdout = BytesIO()
 
156
        stdout = StringIO()
159
157
        action = add.AddAction(to_file=stdout, should_print=bool(output))
160
158
 
161
159
        self.apply_redirected(None, stdout, None, action, inv, None,