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

  • Committer: Jelmer Vernooij
  • Date: 2010-05-02 19:26:28 UTC
  • mto: (0.200.912 trunk)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@samba.org-20100502192628-dy0lavjbjexavvmb
More work on roundtripping support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
    ui,
33
33
    urlutils,
34
34
    )
 
35
from bzrlib.inventory import (
 
36
    InventoryFile,
 
37
    )
35
38
from bzrlib.revision import (
36
39
    NULL_REVISION,
37
40
    )
48
51
    )
49
52
 
50
53
import posixpath
 
54
import stat
51
55
 
52
56
 
53
57
def get_object_store(repo, mapping=None):
325
329
            roundtrip)
326
330
 
327
331
    def _revision_to_objects(self, rev, tree, roundtrip):
 
332
        """Convert a revision to a set of git objects.
 
333
 
 
334
        :param rev: Bazaar revision object
 
335
        :param tree: Bazaar revision tree
 
336
        :param roundtrip: Whether to roundtrip all Bazaar revision data
 
337
        """
328
338
        unusual_modes = extract_unusual_modes(rev)
329
339
        present_parents = self.repository.has_revisions(rev.parent_ids)
330
340
        parent_trees = self.tree_cache.revision_trees(
331
341
            [p for p in rev.parent_ids if p in present_parents])
332
 
        tree_sha = None
 
342
        root_tree = None
333
343
        for path, obj, ie in _tree_to_objects(tree, parent_trees,
334
344
                self._cache.idmap, unusual_modes):
335
345
            yield path, obj, ie
336
346
            if path == "":
337
 
                tree_sha = obj.id
338
 
        if tree_sha is None:
 
347
                root_tree = obj
 
348
        if root_tree is None:
339
349
            # Pointless commit - get the tree sha elsewhere
340
350
            if not rev.parent_ids:
341
 
                tree_sha = Tree().id
 
351
                root_tree = Tree()
342
352
            else:
343
353
                base_sha1 = self._lookup_revision_sha1(rev.parent_ids[0])
344
 
                tree_sha = self[base_sha1].tree
345
 
        commit_obj = self._reconstruct_commit(rev, tree_sha,
346
 
            roundtrip=roundtrip) # FIXME
 
354
                root_tree = self[base_sha1]
 
355
        if roundtrip:
 
356
            b = self.mapping.export_fileid_map({}) # FIXME
 
357
            if b is not None:
 
358
                root_tree[self.mapping.BZR_FILE_IDS_FILE] = ((stat.S_IFREG | 0644), b.id)
 
359
                yield self.mapping.BZR_FILE_IDS_FILE, b, None
 
360
        commit_obj = self._reconstruct_commit(rev, root_tree.id, roundtrip=roundtrip)
347
361
        try:
348
362
            foreign_revid, mapping = mapping_registry.parse_revision_id(
349
363
                rev.revision_id)
360
374
        rev = self.repository.get_revision(revid)
361
375
        tree = self.tree_cache.revision_tree(rev.revision_id)
362
376
        updater = self._get_updater(rev)
363
 
        # FIXME: roundtrip=True AND roundtrip=False
364
377
        for path, obj, ie in self._revision_to_objects(rev, tree,
365
378
            roundtrip=True):
366
379
            updater.add_object(obj, ie)
501
514
                trace.mutter('entry for %s %s in shamap: %r, but not found in '
502
515
                             'repository', type, sha, type_data)
503
516
                raise KeyError(sha)
504
 
            # FIXME
505
517
            commit = self._reconstruct_commit(rev, tree_sha, roundtrip=True)
506
518
            _check_expected_sha(sha, commit)
507
519
            return commit