/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

  • Committer: John Carr
  • Date: 2009-01-13 20:26:54 UTC
  • mto: (0.217.53 git-serve)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: john.carr@unrouted.co.uk-20090113202654-9hsels0a9r35o7u0
Rename upload-pack and receive-pack so they don't clash with the Git versions

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
from bzrlib.plugins.git import git
29
27
from bzrlib.plugins.git.branch import GitBranch
30
28
from bzrlib.plugins.git.errors import NoSuchRef
31
29
from bzrlib.plugins.git.dir import GitDir
37
35
import urllib
38
36
import urlparse
39
37
 
40
 
import dulwich as git
41
38
from dulwich.pack import PackData, Pack
42
39
 
43
 
# Don't run any tests on GitSmartTransport as it is not intended to be 
44
 
# a full implementation of Transport
45
 
def get_test_permutations():
46
 
    return []
47
 
 
48
40
 
49
41
class GitSmartTransport(Transport):
50
42
 
106
98
        raise NotLocalUrl(self.transport.base)
107
99
 
108
100
 
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
101
class RemoteGitRepository(GitRepository):
132
102
 
133
103
    def __init__(self, gitdir, lockfiles):
142
112
        fd, path = tempfile.mkstemp(suffix=".pack")
143
113
        self.fetch_pack(determine_wants, graph_walker, lambda x: os.write(fd, x), progress)
144
114
        os.close(fd)
145
 
        ret = TemporaryPackIterator(path)
146
 
        return (len(ret), iter(ret.next, None))
 
115
        try:
 
116
            basename = path[:-len(".pack")]
 
117
            p = PackData(path)
 
118
            p.create_index_v2(basename+".idx")
 
119
            for o in Pack(basename).iterobjects():
 
120
                yield o
 
121
        finally:
 
122
            os.remove(path)
147
123
 
148
124
 
149
125
class RemoteGitBranch(GitBranch):