/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-05-06 02:13:25 UTC
  • mfrom: (7490.7.21 work)
  • mto: This revision was merged to the branch mainline in revision 7501.
  • Revision ID: jelmer@jelmer.uk-20200506021325-awbmmqu1zyorz7sj
Merge 3.1 branch.

Show diffs side-by-side

added added

removed removed

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