/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: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-07-28 02:47:10 UTC
  • mfrom: (7519.1.1 merge-3.1)
  • Revision ID: breezy.the.bot@gmail.com-20200728024710-a2ylds219f1lsl62
Merge lp:brz/3.1.

Merged from https://code.launchpad.net/~jelmer/brz/merge-3.1/+merge/388173

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