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

  • Committer: Breezy landing bot
  • Author(s): Gustav Hartvigsson
  • Date: 2021-01-10 18:46:30 UTC
  • mfrom: (7526.1.1 brz-removed-api-doc)
  • mto: This revision was merged to the branch mainline in revision 7532.
  • Revision ID: breezy.the.bot@gmail.com-20210110184630-dxu0g9dqq020uiw6
Drop documentation for removed API API.

Merged from https://code.launchpad.net/~gustav-hartvigsson/brz/removed-api-doc/+merge/396033

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
    )
55
55
from .mapping import (
56
56
    default_mapping,
 
57
    encode_git_path,
57
58
    entry_mode,
58
59
    extract_unusual_modes,
59
60
    mapping_registry,
132
133
        self._cache[tree.get_revision_id()] = tree
133
134
 
134
135
 
135
 
def _find_missing_bzr_revids(graph, want, have):
 
136
def _find_missing_bzr_revids(graph, want, have, shallow=None):
136
137
    """Find the revisions that have to be pushed.
137
138
 
138
139
    :param get_parent_map: Function that returns the parents for a sequence
142
143
    :return: Set of revisions to fetch
143
144
    """
144
145
    handled = set(have)
 
146
    if shallow:
 
147
        # Shallows themselves still need to be fetched, but let's exclude their
 
148
        # parents.
 
149
        for ps in graph.get_parent_map(shallow).values():
 
150
            handled.update(ps)
 
151
    handled.add(NULL_REVISION)
145
152
    todo = set()
146
153
    for rev in want:
147
154
        extra_todo = graph.find_unique_ancestors(rev, handled)
148
155
        todo.update(extra_todo)
149
156
        handled.update(extra_todo)
150
 
    if NULL_REVISION in todo:
151
 
        todo.remove(NULL_REVISION)
152
157
    return todo
153
158
 
154
159
 
195
200
            mode = entry_mode(value)
196
201
        hexsha = lookup_ie_sha1(child_path, value)
197
202
        if hexsha is not None:
198
 
            tree.add(value.name.encode("utf-8"), mode, hexsha)
 
203
            tree.add(encode_git_path(value.name), mode, hexsha)
199
204
    if not allow_empty and len(tree) == 0:
200
205
        # Only the root can be an empty tree
201
206
        if empty_file_name is not None:
304
309
    for (path, file_id), chunks in tree.iter_files_bytes(
305
310
            [(path, (path, file_id)) for (path, file_id) in new_blobs]):
306
311
        obj = Blob()
307
 
        obj.chunked = chunks
 
312
        obj.chunked = list(chunks)
308
313
        if add_cache_entry is not None:
309
314
            add_cache_entry(obj, (file_id, tree.get_file_revision(path)), path)
310
315
        yield path, obj, (file_id, tree.get_file_revision(path))
565
570
            ((key[0], key[1], key) for key in keys))
566
571
        for (file_id, revision, expected_sha), chunks in stream:
567
572
            blob = Blob()
568
 
            blob.chunked = chunks
 
573
            blob.chunked = list(chunks)
569
574
            if blob.id != expected_sha and blob.data == b"":
570
575
                # Perhaps it's a symlink ?
571
576
                tree = self.tree_cache.revision_tree(revision)
755
760
        else:
756
761
            raise KeyError(sha)
757
762
 
758
 
    def generate_lossy_pack_data(self, have, want, progress=None,
 
763
    def generate_lossy_pack_data(self, have, want, shallow=None,
 
764
                                 progress=None,
759
765
                                 get_tagged=None, ofs_delta=False):
760
766
        return pack_objects_to_data(
761
 
            self.generate_pack_contents(have, want, progress, get_tagged,
 
767
            self.generate_pack_contents(have, want, progress=progress,
 
768
                                        shallow=shallow, get_tagged=get_tagged,
762
769
                                        lossy=True))
763
770
 
764
 
    def generate_pack_contents(self, have, want, progress=None,
 
771
    def generate_pack_contents(self, have, want, shallow=None, progress=None,
765
772
                               ofs_delta=False, get_tagged=None, lossy=False):
766
773
        """Iterate over the contents of a pack file.
767
774
 
790
797
                    pending.add(type_data[0])
791
798
            except KeyError:
792
799
                pass
 
800
        shallows = set()
 
801
        for commit_sha in shallow or set():
 
802
            try:
 
803
                for (type, type_data) in ret[commit_sha]:
 
804
                    if type != "commit":
 
805
                        raise AssertionError("Type was %s, not commit" % type)
 
806
                    shallows.add(type_data[0])
 
807
            except KeyError:
 
808
                pass
793
809
 
794
810
        graph = self.repository.get_graph()
795
 
        todo = _find_missing_bzr_revids(graph, pending, processed)
 
811
        todo = _find_missing_bzr_revids(graph, pending, processed, shallow)
796
812
        ret = PackTupleIterable(self)
797
813
        with ui.ui_factory.nested_progress_bar() as pb:
798
814
            for i, revid in enumerate(graph.iter_topo_order(todo)):