/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

Add basic infrastructure for dpush.

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