/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

Try to import nothing other than __init__ when not opening git repositories.

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
 
 
131
109
class RemoteGitRepository(GitRepository):
132
110
 
133
111
    def __init__(self, gitdir, lockfiles):
142
120
        fd, path = tempfile.mkstemp(suffix=".pack")
143
121
        self.fetch_pack(determine_wants, graph_walker, lambda x: os.write(fd, x), progress)
144
122
        os.close(fd)
145
 
        ret = TemporaryPackIterator(path)
146
 
        return (len(ret), iter(ret.next, None))
 
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())
147
129
 
148
130
 
149
131
class RemoteGitBranch(GitBranch):