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

  • Committer: Jelmer Vernooij
  • Date: 2018-11-11 04:08:32 UTC
  • mto: (7143.16.20 even-more-cleanups)
  • mto: This revision was merged to the branch mainline in revision 7175.
  • Revision ID: jelmer@jelmer.uk-20181111040832-nsljjynzzwmznf3h
Run autopep8.

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
    """
57
57
 
58
58
    def __init__(self, to_repository, from_repository, last_revision=None,
59
 
        find_ghosts=True, fetch_spec=None):
 
59
                 find_ghosts=True, fetch_spec=None):
60
60
        """Create a repo fetcher.
61
61
 
62
62
        :param last_revision: If set, try to limit to the data this revision
118
118
        # moment, so that it can feed the progress information back to this
119
119
        # function?
120
120
        if (self.from_repository._format.rich_root_data and
121
 
            not self.to_repository._format.rich_root_data):
 
121
                not self.to_repository._format.rich_root_data):
122
122
            raise errors.IncompatibleRepositories(
123
123
                self.from_repository, self.to_repository,
124
124
                "different rich-root support")
164
164
            return vf_search.EmptySearchResult()
165
165
        elif self._last_revision is not None:
166
166
            return vf_search.NotInOtherForRevs(self.to_repository,
167
 
                self.from_repository, [self._last_revision],
168
 
                find_ghosts=self.find_ghosts).execute()
169
 
        else: # self._last_revision is None:
 
167
                                               self.from_repository, [
 
168
                                                   self._last_revision],
 
169
                                               find_ghosts=self.find_ghosts).execute()
 
170
        else:  # self._last_revision is None:
170
171
            return vf_search.EverythingNotInOther(self.to_repository,
171
 
                self.from_repository,
172
 
                find_ghosts=self.find_ghosts).execute()
 
172
                                                  self.from_repository,
 
173
                                                  find_ghosts=self.find_ghosts).execute()
173
174
 
174
175
 
175
176
class Inter1and2Helper(object):
234
235
        rev_order = tsort.topo_sort(parent_map)
235
236
        rev_id_to_root_id = self._find_root_ids(revs, parent_map, graph)
236
237
        root_id_order = [(rev_id_to_root_id[rev_id], rev_id) for rev_id in
237
 
            rev_order]
 
238
                         rev_order]
238
239
        # Guaranteed stable, this groups all the file id operations together
239
240
        # retaining topological order within the revisions of a file id.
240
241
        # File id splits and joins would invalidate this, but they don't exist
249
250
 
250
251
 
251
252
def _new_root_data_stream(
252
 
    root_keys_to_create, rev_id_to_root_id_map, parent_map, repo, graph=None):
 
253
        root_keys_to_create, rev_id_to_root_id_map, parent_map, repo, graph=None):
253
254
    """Generate a texts substream of synthesised root entries.
254
255
 
255
256
    Used in fetches that do rich-root upgrades.
256
 
    
 
257
 
257
258
    :param root_keys_to_create: iterable of (root_id, rev_id) pairs describing
258
259
        the root entries to create.
259
260
    :param rev_id_to_root_id_map: dict of known rev_id -> root_id mappings for
272
273
 
273
274
 
274
275
def _parent_keys_for_root_version(
275
 
    root_id, rev_id, rev_id_to_root_id_map, parent_map, repo, graph=None):
 
276
        root_id, rev_id, rev_id_to_root_id_map, parent_map, repo, graph=None):
276
277
    """Get the parent keys for a given root id.
277
 
    
 
278
 
278
279
    A helper function for _new_root_data_stream.
279
280
    """
280
281
    # Include direct parents of the revision, but only if they used the same
317
318
                pass
318
319
            else:
319
320
                try:
320
 
                    parent_ids.append(tree.get_file_revision(tree.id2path(root_id), root_id))
 
321
                    parent_ids.append(tree.get_file_revision(
 
322
                        tree.id2path(root_id), root_id))
321
323
                except errors.NoSuchId:
322
324
                    # not in the tree
323
325
                    pass
335
337
 
336
338
class TargetRepoKinds(object):
337
339
    """An enum-like set of constants.
338
 
    
 
340
 
339
341
    They are the possible values of FetchSpecFactory.target_repo_kinds.
340
342
    """
341
 
    
 
343
 
342
344
    PREEXISTING = 'preexisting'
343
345
    STACKED = 'stacked'
344
346
    EMPTY = 'empty'
420
422
                graph = self.source_repo.get_graph()
421
423
                topo_order = list(graph.iter_topo_order(ret.get_keys()))
422
424
                result_set = topo_order[:self.limit]
423
 
                ret = self.source_repo.revision_ids_to_search_result(result_set)
 
425
                ret = self.source_repo.revision_ids_to_search_result(
 
426
                    result_set)
424
427
            return ret
425
428
        else:
426
429
            return vf_search.NotInOtherForRevs(self.target_repo, self.source_repo,
427
 
                required_ids=heads_to_fetch, if_present_ids=if_present_fetch,
428
 
                limit=self.limit).execute()
 
430
                                               required_ids=heads_to_fetch, if_present_ids=if_present_fetch,
 
431
                                               limit=self.limit).execute()