/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 set InventoryEntry revision when changing symlink targets.

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