/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:
23
23
from bzrlib.trace import info
24
24
from bzrlib.transport import Transport
25
25
 
 
26
from bzrlib.plugins.git import lazy_check_versions
 
27
lazy_check_versions()
 
28
 
26
29
from bzrlib.plugins.git.branch import GitBranch
27
30
from bzrlib.plugins.git.errors import NoSuchRef
28
31
from bzrlib.plugins.git.dir import GitDir
35
38
import urlparse
36
39
 
37
40
import dulwich as git
38
 
from dulwich.pack import PackData, Pack
 
41
from dulwich.pack import PackData, Pack, PackIndex
39
42
 
40
43
# Don't run any tests on GitSmartTransport as it is not intended to be 
41
44
# a full implementation of Transport
103
106
        raise NotLocalUrl(self.transport.base)
104
107
 
105
108
 
 
109
class TemporaryPackIterator(Pack):
 
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
 
117
 
 
118
    def __del__(self):
 
119
        os.remove(self._data_path)
 
120
        os.remove(self._idx_path)
 
121
 
 
122
 
106
123
class RemoteGitRepository(GitRepository):
107
124
 
108
125
    def __init__(self, gitdir, lockfiles):
117
134
        fd, path = tempfile.mkstemp(suffix=".pack")
118
135
        self.fetch_pack(determine_wants, graph_walker, lambda x: os.write(fd, x), progress)
119
136
        os.close(fd)
120
 
        basename = path[:-len(".pack")]
121
 
        p = PackData(path)
122
 
        p.create_index_v2(basename+".idx")
123
 
        pack = Pack(basename)
124
 
        os.remove(path)
125
 
        return (len(p), pack.iterobjects())
 
137
        return TemporaryPackIterator(path[:-len(".pack")])
126
138
 
127
139
 
128
140
class RemoteGitBranch(GitBranch):