/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

Handle lightweight checkouts.

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 dulwich.object_store import (
 
18
    tree_lookup_path,
 
19
    )
 
20
from dulwich.objects import (
 
21
    Blob,
 
22
    Tree,
 
23
    )
 
24
 
17
25
from bzrlib.revision import (
18
26
    NULL_REVISION,
19
27
    )
24
32
    )
25
33
 
26
34
from bzrlib.plugins.git.converter import (
27
 
    GitObjectConverter,
 
35
    BazaarObjectStore,
28
36
    )
29
37
 
30
38
class GitTexts(VersionedFiles):
 
39
    """A texts VersionedFiles instance that is backed onto a Git object store."""
31
40
 
32
41
    def __init__(self, repository):
33
42
        self.repository = repository
34
 
        
 
43
        self.object_store = self.repository._git.object_store
35
44
 
36
45
    def check(self, progressbar=None):
37
46
        return True
43
52
        for key in keys:
44
53
            (fileid, revid) = key
45
54
            (foreign_revid, mapping) = self.repository.lookup_git_revid(revid)
46
 
            idmap = GitObjectConverter(self.repository, mapping)._idmap
 
55
            root_tree = self.object_store[foreign_revid].tree
47
56
            path = mapping.parse_file_id(fileid)
48
57
            try:
49
 
                sha = idmap.lookup_tree(path, revid)
 
58
                obj = tree_lookup_path(self.object_store, root_tree, path)
50
59
            except KeyError:
51
 
                try:
52
 
                    sha = idmap.lookup_blob(fileid, revid)
53
 
                except KeyError:
 
60
                yield AbsentContentFactory(key)
 
61
            else:
 
62
                if isinstance(obj, Tree):
 
63
                    yield FulltextContentFactory(key, None, None, "")
 
64
                elif isinstance(obj, Blob):
 
65
                    yield FulltextContentFactory(key, None, None, obj._text)
 
66
                else:
54
67
                    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)
60
68
 
61
69
    def get_parent_map(self, keys):
62
70
        raise NotImplementedError(self.get_parent_map)