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

Support submodules during fetch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import tempfile
19
19
 
20
20
from dulwich.server import TCPGitServer
21
 
import os
22
21
 
23
22
from bzrlib.bzrdir import (
24
23
    BzrDir,
47
46
    PackData,
48
47
    write_pack_index_v2,
49
48
    )
50
 
 
 
49
from dulwich.objects import (
 
50
    ShaFile,
 
51
    sha_to_hex,
 
52
    hex_to_sha,
 
53
    )
51
54
 
52
55
class BzrBackend(Backend):
53
56
 
84
87
 
85
88
        p = PackData(path)
86
89
        entries = p.sorted_entries()
 
90
        heads = []
 
91
        for e in entries:
 
92
            sha = e[0]
 
93
            offset = e[1]
 
94
            t, o = p.get_object_at (offset)
 
95
            if t == 1 or t == 4:
 
96
                heads.append(sha)
87
97
        write_pack_index_v2(path[:-5]+".idx", entries, p.calculate_checksum())
88
98
 
89
 
        def get_objects():
90
 
            pack = Pack(path[:-5])
91
 
            for obj in pack.iterobjects():
92
 
                yield obj
 
99
        repo_dir = BzrDir.open_from_transport(self.transport)
 
100
        target = repo_dir.find_repository()
93
101
 
94
 
        target = Repository.open_from_transport(self.transport)
 
102
        objects = {}
 
103
        for tup in p.iterobjects():
 
104
            obj_type, obj = p.get_object_at (tup[0])
 
105
            if obj_type in range(1, 4):
 
106
                sf = ShaFile.from_raw_string (obj_type, obj)
 
107
                objects[hex_to_sha(sf.id)] = sf
95
108
 
96
109
        target.lock_write()
97
110
        try:
98
111
            target.start_write_group()
99
112
            try:
100
 
                import_git_objects(target, self.mapping, iter(get_objects()))
 
113
                import_git_objects(target, self.mapping, objects,
 
114
                                   BazaarObjectStore (target, self.mapping),
 
115
                                   heads)
101
116
            finally:
102
117
                target.commit_write_group()
103
118
        finally:
132
147
            return repo.fetch_objects(determine_wants, graph_walker, None, progress)
133
148
 
134
149
        wants = determine_wants(self.get_refs())
 
150
        graph_walker.reset()
135
151
        repo.lock_read()
136
152
        store = BazaarObjectStore(repo)
137
153
        have = store.find_common_revisions(graph_walker)