/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 simple tests and docstrings for GraphWalker.

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 git
27
26
from bzrlib.plugins.git.branch import GitBranch
28
27
from bzrlib.plugins.git.errors import NoSuchRef
29
28
from bzrlib.plugins.git.dir import GitDir
35
34
import urllib
36
35
import urlparse
37
36
 
 
37
import dulwich as git
38
38
from dulwich.pack import PackData, Pack
39
39
 
 
40
# Don't run any tests on GitSmartTransport as it is not intended to be 
 
41
# a full implementation of Transport
 
42
def get_test_permutations():
 
43
    return []
 
44
 
40
45
 
41
46
class GitSmartTransport(Transport):
42
47
 
89
94
    def open_repository(self):
90
95
        return RemoteGitRepository(self, self._lockfiles)
91
96
 
92
 
    def open_branch(self):
 
97
    def open_branch(self, _unsupported=False):
93
98
        repo = self.open_repository()
94
99
        # TODO: Support for multiple branches in one bzrdir in bzrlib!
95
100
        return RemoteGitBranch(self, repo, "HEAD", self._lockfiles)
112
117
        fd, path = tempfile.mkstemp(suffix=".pack")
113
118
        self.fetch_pack(determine_wants, graph_walker, lambda x: os.write(fd, x), progress)
114
119
        os.close(fd)
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)
 
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())
123
126
 
124
127
 
125
128
class RemoteGitBranch(GitBranch):