/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

Fix remote fetching.

Show diffs side-by-side

added added

removed removed

Lines of Context:
106
106
        raise NotLocalUrl(self.transport.base)
107
107
 
108
108
 
 
109
class TemporaryPackIterator(object):
 
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()
 
119
 
 
120
    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)
 
129
 
 
130
 
109
131
class RemoteGitRepository(GitRepository):
110
132
 
111
133
    def __init__(self, gitdir, lockfiles):
120
142
        fd, path = tempfile.mkstemp(suffix=".pack")
121
143
        self.fetch_pack(determine_wants, graph_walker, lambda x: os.write(fd, x), progress)
122
144
        os.close(fd)
123
 
        basename = path[:-len(".pack")]
124
 
        p = PackData(path)
125
 
        p.create_index_v2(basename+".idx")
126
 
        pack = Pack(basename)
127
 
        os.remove(path)
128
 
        return (len(p), pack.iterobjects())
 
145
        ret = TemporaryPackIterator(path)
 
146
        return (len(ret), iter(ret.next, None))
129
147
 
130
148
 
131
149
class RemoteGitBranch(GitBranch):