/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

mention the requirement to install Dulwich.

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, PackIndex
 
41
from dulwich.pack import PackData, Pack
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(Pack):
 
109
class TemporaryPackIterator(object):
110
110
 
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
 
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()
117
119
 
118
120
    def __del__(self):
119
 
        os.remove(self._data_path)
120
 
        os.remove(self._idx_path)
 
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)
121
129
 
122
130
 
123
131
class RemoteGitRepository(GitRepository):
134
142
        fd, path = tempfile.mkstemp(suffix=".pack")
135
143
        self.fetch_pack(determine_wants, graph_walker, lambda x: os.write(fd, x), progress)
136
144
        os.close(fd)
137
 
        return TemporaryPackIterator(path[:-len(".pack")])
 
145
        ret = TemporaryPackIterator(path)
 
146
        return (len(ret), iter(ret.next, None))
138
147
 
139
148
 
140
149
class RemoteGitBranch(GitBranch):