/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: 2009-09-10 13:13:15 UTC
  • mto: (0.200.602 trunk)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@samba.org-20090910131315-6890xg58pl2jseml
Allow serving remote URLs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
260
260
            "Unknown kind, perms=%r." % (mode,))
261
261
 
262
262
 
263
 
def entry_mode(entry):
264
 
    """Determine the git file mode for an inventory entry."""
265
 
    if entry.kind == 'directory':
 
263
def object_mode(kind, executable):
 
264
    if kind == 'directory':
266
265
        return stat.S_IFDIR
267
 
    elif entry.kind == 'symlink':
 
266
    elif kind == 'symlink':
268
267
        return stat.S_IFLNK
269
 
    elif entry.kind == 'file':
 
268
    elif kind == 'file':
270
269
        mode = stat.S_IFREG | 0644
271
 
        if entry.executable:
 
270
        if executable:
272
271
            mode |= 0111
273
272
        return mode
274
273
    else:
275
274
        raise AssertionError
276
275
 
277
276
 
 
277
def entry_mode(entry):
 
278
    """Determine the git file mode for an inventory entry."""
 
279
    return object_mode(entry.kind, entry.executable)
 
280
 
 
281
 
278
282
def directory_to_tree(entry, lookup_ie_sha1, unusual_modes):
279
283
    from dulwich.objects import Tree
280
284
    tree = Tree()
284
288
            mode = unusual_modes[ie.file_id]
285
289
        except KeyError:
286
290
            mode = entry_mode(ie)
287
 
        tree.add(mode, name.encode("utf-8"), lookup_ie_sha1(ie))
 
291
        hexsha = lookup_ie_sha1(ie)
 
292
        if hexsha is not None:
 
293
            tree.add(mode, name.encode("utf-8"), hexsha)
 
294
    if entry.parent_id is not None and len(tree) == 0:
 
295
        # Only the root can be an empty tree
 
296
        return None
288
297
    tree.serialize()
289
298
    return tree
290
299