/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: Gustav Hartvigsson
  • Date: 2021-01-09 21:36:27 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20210109213627-h1xwcutzy9m7a99b
Added 'Case Preserving Working Tree Use Cases' from Canonical Wiki

* Addod a page from the Canonical Bazaar wiki
  with information on the scmeatics of case
  perserving filesystems an a case insensitive
  filesystem works.
  
  * Needs re-work, but this will do as it is the
    same inforamoton as what was on the linked
    page in the currint documentation.

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