/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/upstream_import.py

  • Committer: Jelmer Vernooij
  • Date: 2020-03-22 20:02:36 UTC
  • mto: (7490.7.7 work)
  • mto: This revision was merged to the branch mainline in revision 7501.
  • Revision ID: jelmer@jelmer.uk-20200322200236-fsbl91ktcn6fcbdd
Fix tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Import upstream source into a branch"""
18
18
 
 
19
from __future__ import absolute_import
 
20
 
19
21
import errno
20
22
from io import (
21
23
    BytesIO,
29
31
from . import urlutils
30
32
from .bzr import generate_ids
31
33
from .controldir import ControlDir, is_control_filename
32
 
from .errors import (BzrError, NoSuchFile, CommandError, NotBranchError)
 
34
from .errors import (BzrError, NoSuchFile, BzrCommandError, NotBranchError)
33
35
from .osutils import (pathjoin, isdir, file_iterator, basename,
34
36
                      file_kind, splitpath)
 
37
from .sixish import (
 
38
    text_type,
 
39
    )
35
40
from .trace import warning
36
41
from .transform import resolve_conflicts, cook_conflicts
37
42
from .transport import get_transport
227
232
 
228
233
 
229
234
def import_archive(tree, archive_file):
230
 
    with tree.transform() as tt:
 
235
    with tree.get_transform() as tt:
231
236
        import_archive_to_transform(tree, archive_file, tt)
232
237
        tt.apply()
233
238
 
253
258
        # interpret relative to fs encoding, which would match native
254
259
        # behaviour better.
255
260
        relative_path = member.name
256
 
        if not isinstance(relative_path, str):
 
261
        if not isinstance(relative_path, text_type):
257
262
            relative_path = relative_path.decode('utf-8')
258
263
        if prefix is not None:
259
264
            relative_path = relative_path[len(prefix) + 1:]
285
290
        if tt.tree_file_id(trans_id) is None:
286
291
            name = basename(member.name.rstrip('/'))
287
292
            file_id = generate_ids.gen_file_id(name)
288
 
            tt.version_file(trans_id, file_id=file_id)
 
293
            tt.version_file(file_id, trans_id)
289
294
 
290
295
    for relative_path in implied_parents.difference(added):
291
296
        if relative_path == "":
294
299
        path = tree.abspath(relative_path)
295
300
        do_directory(tt, trans_id, tree, relative_path, path)
296
301
        if tt.tree_file_id(trans_id) is None:
297
 
            tt.version_file(trans_id, file_id=trans_id)
 
302
            tt.version_file(trans_id, trans_id)
298
303
        added.add(relative_path)
299
304
 
300
305
    for path in removed.difference(added):
318
323
        tree = WorkingTree.open_containing('.')[0]
319
324
    with tree.lock_write():
320
325
        if tree.changes_from(tree.basis_tree()).has_changed():
321
 
            raise CommandError("Working tree has uncommitted changes.")
 
326
            raise BzrCommandError("Working tree has uncommitted changes.")
322
327
 
323
328
        try:
324
329
            archive, external_compressor = get_archive_type(source)
328
333
                s.seek(0)
329
334
                import_dir(tree, s)
330
335
            else:
331
 
                raise CommandError('Unhandled import source')
 
336
                raise BzrCommandError('Unhandled import source')
332
337
        else:
333
338
            if archive == 'zip':
334
339
                import_zip(tree, open_from_url(source))