/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 fetch.py

Add basic infrastructure for dpush.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from bzrlib.trace import info
22
22
from bzrlib.tsort import topo_sort
23
23
 
24
 
from bzrlib.plugins.git import git
25
24
from bzrlib.plugins.git.repository import (
26
25
        LocalGitRepository, 
27
26
        GitRepository, 
29
28
        )
30
29
from bzrlib.plugins.git.remote import RemoteGitRepository
31
30
 
 
31
import dulwich as git
32
32
from dulwich.client import SimpleFetchGraphWalker
33
33
from dulwich.objects import Commit
34
34
 
36
36
 
37
37
 
38
38
class BzrFetchGraphWalker(object):
 
39
    """GraphWalker implementation that uses a Bazaar repository."""
39
40
 
40
41
    def __init__(self, repository, mapping):
41
42
        self.repository = repository
44
45
        self.heads = set(repository.all_revision_ids())
45
46
        self.parents = {}
46
47
 
 
48
    def __iter__(self):
 
49
        return iter(self.next, None)
 
50
 
47
51
    def ack(self, sha):
48
52
        revid = self.mapping.revision_id_foreign_to_bzr(sha)
49
53
        self.remove(revid)
64
68
            self.heads.update([p for p in ps if not p in self.done])
65
69
            try:
66
70
                self.done.add(ret)
67
 
                return self.mapping.revision_id_bzr_to_foreign(ret)
 
71
                return self.mapping.revision_id_bzr_to_foreign(ret)[0]
68
72
            except InvalidRevisionId:
69
73
                pass
70
74
        return None
132
136
    """
133
137
    # TODO: a more (memory-)efficient implementation of this
134
138
    objects = {}
135
 
    for i, o in enumerate(object_iter):
 
139
    for i, (o, _) in enumerate(object_iter):
136
140
        if pb is not None:
137
141
            pb.update("fetching objects", i, num_objects) 
138
142
        objects[o.id] = o
209
213
            if revision_id is None:
210
214
                ret = heads.values()
211
215
            else:
212
 
                ret = [mapping.revision_id_bzr_to_foreign(revision_id)]
 
216
                ret = [mapping.revision_id_bzr_to_foreign(revision_id)[0]]
213
217
            return [rev for rev in ret if not self.target.has_revision(mapping.revision_id_foreign_to_bzr(rev))]
214
218
        graph_walker = BzrFetchGraphWalker(self.target, mapping)
215
219
        create_pb = None
264
268
        if revision_id is None:
265
269
            determine_wants = lambda x: [y for y in x.values() if not y in r.object_store]
266
270
        else:
267
 
            args = [mapping.revision_id_bzr_to_foreign(revision_id)]
 
271
            args = [mapping.revision_id_bzr_to_foreign(revision_id)[0]]
268
272
            determine_wants = lambda x: [y for y in args if not y in r.object_store]
269
273
 
270
274
        graphwalker = SimpleFetchGraphWalker(r.heads().values(), r.get_parents)