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

Add FOSDEM roundtripping notes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
import urlparse
39
39
 
40
40
import dulwich as git
41
 
from dulwich.pack import PackData, Pack
 
41
from dulwich.pack import PackData, Pack, PackIndex
42
42
 
43
43
# Don't run any tests on GitSmartTransport as it is not intended to be 
44
44
# a full implementation of Transport
106
106
        raise NotLocalUrl(self.transport.base)
107
107
 
108
108
 
109
 
class TemporaryPackIterator(object):
 
109
class TemporaryPackIterator(Pack):
110
110
 
111
 
    def __init__(self, path):
112
 
        self.path_data = path
113
 
        basename = path[:-len(".pack")]
114
 
        p = PackData(path)
115
 
        self.path_idx = basename+".idx"
116
 
        p.create_index_v2(self.path_idx)
117
 
        self.pack = Pack(basename)
118
 
        self._iter = self.pack.iterobjects()
 
111
    @property
 
112
    def idx(self):
 
113
        if self._idx is None:
 
114
            self._data.create_index_v2(self._idx_path)
 
115
            self._idx = PackIndex(self._idx_path)
 
116
        return self._idx
119
117
 
120
118
    def __del__(self):
121
 
        os.remove(self.path_data)
122
 
        os.remove(self.path_idx)
123
 
 
124
 
    def next(self):
125
 
        return (self._iter.next(), None)
126
 
 
127
 
    def __len__(self):
128
 
        return len(self.pack)
 
119
        os.remove(self._data_path)
 
120
        os.remove(self._idx_path)
129
121
 
130
122
 
131
123
class RemoteGitRepository(GitRepository):
142
134
        fd, path = tempfile.mkstemp(suffix=".pack")
143
135
        self.fetch_pack(determine_wants, graph_walker, lambda x: os.write(fd, x), progress)
144
136
        os.close(fd)
145
 
        ret = TemporaryPackIterator(path)
146
 
        return (len(ret), iter(ret.next, None))
 
137
        return TemporaryPackIterator(path[:-len(".pack")])
147
138
 
148
139
 
149
140
class RemoteGitBranch(GitBranch):