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

More work on roundtrip push support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
from dulwich.objects import (
26
26
    Blob,
27
27
    )
 
28
from dulwich.protocol import (
 
29
    ZERO_SHA,
 
30
    )
28
31
import os
29
32
import stat
30
33
 
50
53
    changes_from_git_changes,
51
54
    tree_delta_from_git_changes,
52
55
    )
53
 
 
 
56
from bzrlib.plugins.git.mapping import (
 
57
    GitFileIdMap,
 
58
    )
54
59
 
55
60
IGNORE_FILENAME = ".gitignore"
56
61
 
145
150
        # TODO: Maybe this should only write on dirty ?
146
151
        if self._control_files._lock_mode != 'w':
147
152
            raise errors.NotWriteLocked(self)
148
 
        self._rewrite_index()           
 
153
        self._rewrite_index()
149
154
        self.index.write()
150
155
        self._inventory_is_modified = False
151
156
 
175
180
            head = self.repository._git.head()
176
181
        except KeyError, name:
177
182
            raise errors.NotBranchError("branch %s at %s" % (name, self.repository.base))
178
 
        basis_inv = self.repository.get_inventory(self.mapping.revision_id_foreign_to_bzr(head))
179
 
        result = GitIndexInventory(basis_inv, self.mapping, self.index,
180
 
            self.repository._git.object_store)
 
183
        basis_inv = self.repository.get_inventory(self.branch.lookup_foreign_revision_id(head))
 
184
        store = self.repository._git.object_store
 
185
        if head == ZERO_SHA:
 
186
            fileid_map = GitFileIdMap({}, self.mapping)
 
187
            basis_inv = None
 
188
        else:
 
189
            fileid_map = self.mapping.get_fileid_map(store.__getitem__,
 
190
                store[head].tree)
 
191
        result = GitIndexInventory(basis_inv, fileid_map, self.index, store)
181
192
        self._set_inventory(result, dirty=False)
182
193
 
183
194
    @needs_read_lock
204
215
 
205
216
    @property
206
217
    def _matchingbzrdir(self):
207
 
        from bzrlib.plugins.git import LocalGitBzrDirFormat
208
 
        return LocalGitBzrDirFormat()
 
218
        from bzrlib.plugins.git import LocalGitControlDirFormat
 
219
        return LocalGitControlDirFormat()
209
220
 
210
221
    def get_format_description(self):
211
222
        return "Git Working Tree"
230
241
        changes = self._index.changes_from_tree(
231
242
            self.source._repository._git.object_store, self.source.tree, 
232
243
            want_unchanged=want_unchanged)
233
 
        ret = tree_delta_from_git_changes(changes, self.target.mapping, 
 
244
        source_fileid_map = self.source.mapping.get_fileid_map(
 
245
            self.source._repository._git.object_store.__getitem__,
 
246
            self.source.tree)
 
247
        if self.target.mapping.BZR_FILE_IDS_FILE is not None:
 
248
            file_id = self.target.path2id(
 
249
                self.target.mapping.BZR_FILE_IDS_FILE)
 
250
            if file_id is None:
 
251
                target_fileid_map = {}
 
252
            else:
 
253
                target_fileid_map = self.target.mapping.import_fileid_map(Blob.from_string(self.target.get_file_text(file_id)))
 
254
        else:
 
255
            target_fileid_map = {}
 
256
        target_fileid_map = GitFileIdMap(target_fileid_map, self.target.mapping)
 
257
        ret = tree_delta_from_git_changes(changes, self.target.mapping,
 
258
            (source_fileid_map, target_fileid_map),
234
259
            specific_file=specific_files, require_versioned=require_versioned)
235
260
        if want_unversioned:
236
261
            for e in self.target.extras():