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

  • Committer: Jelmer Vernooij
  • Date: 2009-03-28 22:27:07 UTC
  • mto: (0.200.305 trunk)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@samba.org-20090328222707-n0y980ntev40xqd2
Fix blob lookup.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
from bzrlib.revision import NULL_REVISION
18
 
from bzrlib.versionedfile import VersionedFiles, AbsentContentFactory
 
17
from bzrlib.revision import (
 
18
    NULL_REVISION,
 
19
    )
 
20
from bzrlib.versionedfile import (
 
21
    AbsentContentFactory,
 
22
    FulltextContentFactory,
 
23
    VersionedFiles,
 
24
    )
 
25
 
 
26
from bzrlib.plugins.git.converter import (
 
27
    GitObjectConverter,
 
28
    )
19
29
 
20
30
class GitTexts(VersionedFiles):
21
31
 
22
32
    def __init__(self, repository):
23
33
        self.repository = repository
 
34
        
24
35
 
25
36
    def check(self, progressbar=None):
26
37
        return True
30
41
 
31
42
    def get_record_stream(self, keys, ordering, include_delta_closure):
32
43
        for key in keys:
33
 
            yield AbsentContentFactory(key)
 
44
            (fileid, revid) = key
 
45
            (foreign_revid, mapping) = self.repository.revision_id_bzr_to_foreign(revid)
 
46
            idmap = GitObjectConverter(self.repository, mapping)._idmap
 
47
            path = mapping.parse_file_id(fileid)
 
48
            try:
 
49
                sha = idmap.lookup_tree(path, revid)
 
50
            except KeyError:
 
51
                try:
 
52
                    sha = idmap.lookup_blob(fileid, revid)
 
53
                except KeyError:
 
54
                    yield AbsentContentFactory(key)
 
55
                else:
 
56
                    blob = self.repository.object_store[sha]
 
57
                    yield FulltextContentFactory(key, None, None, "")
 
58
            else:
 
59
                yield FulltextContentFactory(key, None, None, blob)
34
60
 
35
61
    def get_parent_map(self, keys):
36
62
        raise NotImplementedError(self.get_parent_map)
37
63
 
38
 
 
39