/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/plugins/fastimport/revision_store.py

  • Committer: Jelmer Vernooij
  • Date: 2018-10-30 02:24:12 UTC
  • mto: This revision was merged to the branch mainline in revision 7170.
  • Revision ID: jelmer@jelmer.uk-20181030022412-33hzkg6wg2tfimu4
Fix more tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
        self._inv_delta = inv_delta
47
47
        self._new_info_by_id = dict([(file_id, (new_path, ie))
48
48
                                    for _, new_path, file_id, ie in inv_delta])
 
49
        self._new_info_by_path = {new_path: ie
 
50
                                  for _, new_path, file_id, ie in inv_delta}
49
51
 
50
52
    def id2path(self, file_id):
51
53
        if file_id in self._new_info_by_id:
61
63
        # need more than just root, is to defer to basis_inv.path2id() and then
62
64
        # check if the file_id is in our _new_info_by_id dict. And in that
63
65
        # case, return _new_info_by_id[file_id][0]
64
 
        if path != '':
65
 
            raise NotImplementedError(_TreeShim.path2id)
66
 
        # TODO: Handle root renames?
67
 
        return self._basis_inv.root.file_id
 
66
        try:
 
67
            return self._new_info_by_path[path].file_id
 
68
        except KeyError:
 
69
            return self._basis_inv.path2id(path)
68
70
 
69
 
    def get_file_with_stat(self, path, file_id=None):
70
 
        content = self.get_file_text(path, file_id)
 
71
    def get_file_with_stat(self, path):
 
72
        content = self.get_file_text(path)
71
73
        sio = BytesIO(content)
72
74
        return sio, None
73
75
 
74
 
    def get_file_text(self, path, file_id=None):
75
 
        if file_id is None:
76
 
            file_id = self.path2id(path)
 
76
    def get_file_text(self, path):
 
77
        file_id = self.path2id(path)
77
78
        try:
78
79
            return self._content_provider(file_id)
79
80
        except KeyError:
85
86
                                                        'unordered', True)
86
87
            return next(stream).get_bytes_as('fulltext')
87
88
 
88
 
    def get_symlink_target(self, path, file_id=None):
89
 
        if file_id is None:
 
89
    def get_symlink_target(self, path):
 
90
        try:
 
91
            ie = self._new_info_by_path[path]
 
92
        except KeyError:
90
93
            file_id = self.path2id(path)
91
 
        if file_id in self._new_info_by_id:
92
 
            ie = self._new_info_by_id[file_id][1]
 
94
            return self._basis_inv.get_entry(file_id).symlink_target
 
95
        else:
93
96
            return ie.symlink_target
94
 
        return self._basis_inv.get_entry(file_id).symlink_target
95
97
 
96
 
    def get_reference_revision(self, path, file_id=None):
 
98
    def get_reference_revision(self, path):
97
99
        raise NotImplementedError(_TreeShim.get_reference_revision)
98
100
 
99
101
    def _delta_to_iter_changes(self):
227
229
        """Get the text stored for a file in a given revision."""
228
230
        revtree = self.repo.revision_tree(revision_id)
229
231
        path = revtree.id2path(file_id)
230
 
        return revtree.get_file_text(path, file_id)
 
232
        return revtree.get_file_text(path)
231
233
 
232
234
    def get_file_lines(self, revision_id, file_id):
233
235
        """Get the lines stored for a file in a given revision."""
234
236
        revtree = self.repo.revision_tree(revision_id)
235
237
        path = revtree.id2path(file_id)
236
 
        return osutils.split_lines(revtree.get_file_text(path, file_id))
 
238
        return osutils.split_lines(revtree.get_file_text(path))
237
239
 
238
240
    def start_new_revision(self, revision, parents, parent_invs):
239
241
        """Init the metadata needed for get_parents_and_revision_for_entry().