/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/git/fetch.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
"""Fetching from git into bzr."""
18
18
 
19
 
from __future__ import absolute_import
20
 
 
21
19
from dulwich.objects import (
22
20
    Commit,
23
21
    Tag,
51
49
    NULL_REVISION,
52
50
    )
53
51
from ..bzr.inventorytree import InventoryRevisionTree
54
 
from ..sixish import text_type
55
52
from ..bzr.testament import (
56
53
    StrictTestament3,
57
54
    )
65
62
 
66
63
from .mapping import (
67
64
    DEFAULT_FILE_MODE,
 
65
    decode_git_path,
68
66
    mode_is_executable,
69
67
    mode_kind,
70
68
    warn_unusual_mode,
88
86
    """
89
87
    if not isinstance(path, bytes):
90
88
        raise TypeError(path)
91
 
    decoded_path = path.decode('utf-8')
 
89
    decoded_path = decode_git_path(path)
92
90
    (base_mode, mode) = modes
93
91
    (base_hexsha, hexsha) = hexshas
94
92
    if mapping.is_special_file(path):
101
99
        cls = InventoryLink
102
100
    else:
103
101
        cls = InventoryFile
104
 
    ie = cls(file_id, name.decode("utf-8"), parent_id)
 
102
    ie = cls(file_id, decode_git_path(name), parent_id)
105
103
    if ie.kind == "file":
106
104
        ie.executable = mode_is_executable(mode)
107
105
    if base_hexsha == hexsha and mode_kind(base_mode) == mode_kind(mode):
119
117
        blob = lookup_object(hexsha)
120
118
        if ie.kind == "symlink":
121
119
            ie.revision = None
122
 
            ie.symlink_target = blob.data.decode("utf-8")
 
120
            ie.symlink_target = decode_git_path(blob.data)
123
121
        else:
124
122
            ie.text_size = sum(map(len, blob.chunked))
125
123
            ie.text_sha1 = osutils.sha_strings(blob.chunked)
186
184
    (base_mode, mode) = modes
187
185
    if base_hexsha == hexsha and base_mode == mode:
188
186
        return [], {}
189
 
    path = path.decode('utf-8')
 
187
    path = decode_git_path(path)
190
188
    file_id = lookup_file_id(path)
191
189
    invdelta = []
192
 
    ie = TreeReference(file_id, name.decode("utf-8"), parent_id)
 
190
    ie = TreeReference(file_id, decode_git_path(name), parent_id)
193
191
    ie.revision = revision_id
194
192
    if base_hexsha is not None:
195
193
        old_path = path  # Renames are not supported yet
218
216
    :param lookup_object: Lookup a git object by its SHA1
219
217
    :return: Inventory delta, as list
220
218
    """
221
 
    if not isinstance(path, text_type):
 
219
    if not isinstance(path, str):
222
220
        raise TypeError(path)
223
221
    ret = []
224
222
    for name, mode, hexsha in base_tree.iteritems():
225
223
        if name in existing_children:
226
224
            continue
227
 
        c_path = posixpath.join(path, name.decode("utf-8"))
 
225
        c_path = posixpath.join(path, decode_git_path(name))
228
226
        file_id = base_bzr_tree.path2id(c_path)
229
227
        if file_id is None:
230
228
            raise TypeError(file_id)
261
259
        return [], {}
262
260
    invdelta = []
263
261
    file_id = lookup_file_id(osutils.safe_unicode(path))
264
 
    # We just have to hope this is indeed utf-8:
265
 
    ie = InventoryDirectory(file_id, name.decode("utf-8"), parent_id)
 
262
    ie = InventoryDirectory(file_id, decode_git_path(name), parent_id)
266
263
    tree = lookup_object(hexsha)
267
264
    if base_hexsha is None:
268
265
        base_tree = None
269
266
        old_path = None  # Newly appeared here
270
267
    else:
271
268
        base_tree = lookup_object(base_hexsha)
272
 
        old_path = path.decode("utf-8")  # Renames aren't supported yet
273
 
    new_path = path.decode("utf-8")
 
269
        old_path = decode_git_path(path)  # Renames aren't supported yet
 
270
    new_path = decode_git_path(path)
274
271
    if base_tree is None or type(base_tree) is not Tree:
275
272
        ie.revision = revision_id
276
273
        invdelta.append((old_path, new_path, ie.file_id, ie))