/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: Jelmer Vernooij
  • Date: 2020-06-15 01:29:36 UTC
  • mfrom: (7490.40.4 work)
  • mto: (7490.40.19 work)
  • mto: This revision was merged to the branch mainline in revision 7516.
  • Revision ID: jelmer@jelmer.uk-20200615012936-1adqbu592y7lzmy8
Merge upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
135
135
        self._cache[tree.get_revision_id()] = tree
136
136
 
137
137
 
138
 
def _find_missing_bzr_revids(graph, want, have):
 
138
def _find_missing_bzr_revids(graph, want, have, shallow=None):
139
139
    """Find the revisions that have to be pushed.
140
140
 
141
141
    :param get_parent_map: Function that returns the parents for a sequence
145
145
    :return: Set of revisions to fetch
146
146
    """
147
147
    handled = set(have)
 
148
    if shallow:
 
149
        # Shallows themselves still need to be fetched, but let's exclude their
 
150
        # parents.
 
151
        for ps in graph.get_parent_map(shallow).values():
 
152
            handled.update(ps)
 
153
    handled.add(NULL_REVISION)
148
154
    todo = set()
149
155
    for rev in want:
150
156
        extra_todo = graph.find_unique_ancestors(rev, handled)
151
157
        todo.update(extra_todo)
152
158
        handled.update(extra_todo)
153
 
    if NULL_REVISION in todo:
154
 
        todo.remove(NULL_REVISION)
155
159
    return todo
156
160
 
157
161
 
758
762
        else:
759
763
            raise KeyError(sha)
760
764
 
761
 
    def generate_lossy_pack_data(self, have, want, progress=None,
 
765
    def generate_lossy_pack_data(self, have, want, shallow=None,
 
766
                                 progress=None,
762
767
                                 get_tagged=None, ofs_delta=False):
763
768
        return pack_objects_to_data(
764
 
            self.generate_pack_contents(have, want, progress, get_tagged,
 
769
            self.generate_pack_contents(have, want, progress=progress,
 
770
                                        shallow=shallow, get_tagged=get_tagged,
765
771
                                        lossy=True))
766
772
 
767
 
    def generate_pack_contents(self, have, want, progress=None,
 
773
    def generate_pack_contents(self, have, want, shallow=None, progress=None,
768
774
                               ofs_delta=False, get_tagged=None, lossy=False):
769
775
        """Iterate over the contents of a pack file.
770
776
 
793
799
                    pending.add(type_data[0])
794
800
            except KeyError:
795
801
                pass
 
802
        shallows = set()
 
803
        for commit_sha in shallow or set():
 
804
            try:
 
805
                for (type, type_data) in ret[commit_sha]:
 
806
                    if type != "commit":
 
807
                        raise AssertionError("Type was %s, not commit" % type)
 
808
                    shallows.add(type_data[0])
 
809
            except KeyError:
 
810
                pass
796
811
 
797
812
        graph = self.repository.get_graph()
798
 
        todo = _find_missing_bzr_revids(graph, pending, processed)
 
813
        todo = _find_missing_bzr_revids(graph, pending, processed, shallow)
799
814
        ret = PackTupleIterable(self)
800
815
        with ui.ui_factory.nested_progress_bar() as pb:
801
816
            for i, revid in enumerate(graph.iter_topo_order(todo)):