/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

  • Committer: Jelmer Vernooij
  • Date: 2010-05-04 19:39:04 UTC
  • mto: (0.200.912 trunk)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@samba.org-20100504193904-m2wac46pz3xcyr10
Support creating dummy files for empty directories.

Show diffs side-by-side

added added

removed removed

Lines of Context:
514
514
    return object_mode(entry.kind, entry.executable)
515
515
 
516
516
 
517
 
def directory_to_tree(entry, lookup_ie_sha1, unusual_modes):
518
 
    from dulwich.objects import Tree
 
517
def directory_to_tree(entry, lookup_ie_sha1, unusual_modes, empty_file_name):
 
518
    """Create a Git Tree object from a Bazaar directory.
 
519
 
 
520
    :param entry: Inventory entry
 
521
    :param lookup_ie_sha1: Lookup the Git SHA1 for a inventory entry
 
522
    :param unusual_modes: Dictionary with unusual file modes by file ids
 
523
    :param empty_file_name: Name to use for dummy files in empty directories,
 
524
        None to ignore empty directories.
 
525
    """
 
526
    from dulwich.objects import Blob, Tree
519
527
    tree = Tree()
520
528
    for name, value in entry.children.iteritems():
521
529
        ie = entry.children[name]
528
536
            tree.add(mode, name.encode("utf-8"), hexsha)
529
537
    if entry.parent_id is not None and len(tree) == 0:
530
538
        # Only the root can be an empty tree
531
 
        return None
 
539
        if empty_file_name is not None:
 
540
            tree.add(stat.S_IFREG | 0644, empty_file_name, 
 
541
                Blob().id)
 
542
        else:
 
543
            return None
532
544
    return tree
533
545
 
534
546