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

properly commit write group

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Push implementation that simply prints message saying push is not supported."""
18
18
 
19
19
from bzrlib import (
 
20
    errors,
20
21
    ui,
21
22
    )
22
23
from bzrlib.repository import (
70
71
            yield (revid, git_commit)
71
72
 
72
73
    def need_sha(self, sha):
73
 
        if sha in self._sent_shas:
 
74
        if sha is None or sha in self._sent_shas:
74
75
            return False
75
76
        (type, (fileid, revid)) = self._object_store._idmap.lookup_git_sha(sha)
76
77
        assert type in ("blob", "tree")
81
82
        # or already present remotely (as git doesn't do ghosts)
82
83
        return False
83
84
 
84
 
    def queue(self, sha, obj, path, ie=None, inv=None):
 
85
    def queue(self, sha, obj, path, ie=None, inv=None, unusual_modes=None):
85
86
        if obj is None:
86
 
            obj = (ie, inv)
 
87
            # Can't lazy-evaluate directories, since they might be eliminated
 
88
            if ie.kind == "directory":
 
89
                obj = self._object_store._get_ie_object(ie, inv, unusual_modes)
 
90
                if obj is None:
 
91
                    return
 
92
            else:
 
93
                obj = (ie, inv, unusual_modes)
87
94
        self._pending.append((obj, path))
88
95
        self._sent_shas.add(sha)
89
96
 
103
110
                tree_sha = sha
104
111
            if not self.need_sha(sha):
105
112
                continue
106
 
            self.queue(sha, object, inv.id2path(ie.file_id), ie, inv)
 
113
            self.queue(sha, object, inv.id2path(ie.file_id), ie, inv, unusual_modes)
107
114
            if ie.kind == "directory":
108
115
                todo.extend(ie.children.values())
109
116
        assert tree_sha is not None
110
117
        commit = self._object_store._get_commit(rev, tree_sha)
111
 
        self.queue(commit.id, commit, None)
 
118
        self.queue(commit.id, commit, None, None)
112
119
        return commit.id
113
120
 
114
121
    def __len__(self):
120
127
                self.pb.update("writing pack objects", i, len(self))
121
128
            if isinstance(object, tuple):
122
129
                object = self._object_store._get_ie_object(*object)
123
 
            yield (object, path)   
 
130
            yield (object, path)
124
131
 
125
132
 
126
133
class InterToGitRepository(InterRepository):
141
148
        """See InterRepository.copy_content."""
142
149
        self.fetch(revision_id, pb, find_ghosts=False)
143
150
 
144
 
    def fetch(self, revision_id=None, pb=None, find_ghosts=False, 
 
151
    def fetch(self, revision_id=None, pb=None, find_ghosts=False,
145
152
            fetch_spec=None):
146
153
        raise NoPushSupport()
147
154
 
183
190
            def check_revid(revid):
184
191
                if revid == NULL_REVISION:
185
192
                    return True
186
 
                return (self.source_store._lookup_revision_sha1(revid) in target_store)
 
193
                try:
 
194
                    return (self.source_store._lookup_revision_sha1(revid) in target_store)
 
195
                except errors.NoSuchRevision:
 
196
                    # Ghost, can't dpush
 
197
                    return True
187
198
            todo = list(self.missing_revisions(stop_revisions, check_revid))
188
199
            pb = ui.ui_factory.nested_progress_bar()
189
200
            try:
193
204
                    new_bzr_revid = self.mapping.revision_id_foreign_to_bzr(git_commit)
194
205
                    revidmap[old_bzr_revid] = new_bzr_revid
195
206
                    gitidmap[old_bzr_revid] = git_commit
196
 
                target_store.add_objects(object_generator) 
 
207
                target_store.add_objects(object_generator)
197
208
            finally:
198
209
                pb.finished()
199
210
        finally:
203
214
    @staticmethod
204
215
    def is_compatible(source, target):
205
216
        """Be compatible with GitRepository."""
206
 
        return (not isinstance(source, GitRepository) and 
 
217
        return (not isinstance(source, GitRepository) and
207
218
                isinstance(target, LocalGitRepository))
208
219
 
209
220
 
228
239
    @staticmethod
229
240
    def is_compatible(source, target):
230
241
        """Be compatible with GitRepository."""
231
 
        return (not isinstance(source, GitRepository) and 
 
242
        return (not isinstance(source, GitRepository) and
232
243
                isinstance(target, RemoteGitRepository))