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

Avoid using file ids in object store code.

Merged from https://code.launchpad.net/~jelmer/brz-git/no-push-file-ids/+merge/342827

Show diffs side-by-side

added added

removed removed

Lines of Context:
181
181
        except KeyError:
182
182
            return {}
183
183
        else:
184
 
            return dict([(self.generate_file_id(path), mode) for (path, mode) in bencode.bdecode(file_modes.encode("utf-8"))])
 
184
            return dict(bencode.bdecode(file_modes.encode("utf-8")))
185
185
 
186
186
    def _generate_git_svn_metadata(self, rev, encoding):
187
187
        try:
602
602
    return object_mode(entry.kind, entry.executable)
603
603
 
604
604
 
605
 
def directory_to_tree(children, lookup_ie_sha1, unusual_modes, empty_file_name,
606
 
                      allow_empty=False):
607
 
    """Create a Git Tree object from a Bazaar directory.
608
 
 
609
 
    :param children: Children inventory entries
610
 
    :param lookup_ie_sha1: Lookup the Git SHA1 for a inventory entry
611
 
    :param unusual_modes: Dictionary with unusual file modes by file ids
612
 
    :param empty_file_name: Name to use for dummy files in empty directories,
613
 
        None to ignore empty directories.
614
 
    """
615
 
    from dulwich.objects import Blob, Tree
616
 
    tree = Tree()
617
 
    for name, value in children.iteritems():
618
 
        ie = children[name]
619
 
        try:
620
 
            mode = unusual_modes[ie.file_id]
621
 
        except KeyError:
622
 
            mode = entry_mode(ie)
623
 
        hexsha = lookup_ie_sha1(ie)
624
 
        if hexsha is not None:
625
 
            tree.add(name.encode("utf-8"), mode, hexsha)
626
 
    if not allow_empty and len(tree) == 0:
627
 
        # Only the root can be an empty tree
628
 
        if empty_file_name is not None:
629
 
            tree.add(empty_file_name, stat.S_IFREG | 0644, Blob().id)
630
 
        else:
631
 
            return None
632
 
    return tree
633
 
 
634
 
 
635
605
def extract_unusual_modes(rev):
636
606
    try:
637
607
        foreign_revid, mapping = mapping_registry.parse_revision_id(