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

Cope with files disappearing during commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
from dulwich.repo import (
43
43
    BaseRepo,
44
44
    RefsContainer,
 
45
    BASE_DIRECTORIES,
45
46
    INDEX_FILENAME,
46
47
    OBJECTDIR,
47
48
    REFSDIR,
312
313
        except NoSuchFile:
313
314
            return None
314
315
 
 
316
    def _put_named_file(self, relpath, contents):
 
317
        self._controltransport.put_bytes(relpath, contents)
 
318
 
315
319
    def index_path(self):
316
320
        """Return the path to the index file."""
317
321
        return self._controltransport.local_abspath(INDEX_FILENAME)
332
336
    def __repr__(self):
333
337
        return "<%s for %r>" % (self.__class__.__name__, self.transport)
334
338
 
 
339
    @classmethod
 
340
    def init(cls, transport, bare=False):
 
341
        if not bare:
 
342
            transport.mkdir(".git")
 
343
            control_transport = transport.clone(".git")
 
344
        else:
 
345
            control_transport = transport
 
346
        for d in BASE_DIRECTORIES:
 
347
            control_transport.mkdir("/".join(d))
 
348
        control_transport.mkdir(OBJECTDIR)
 
349
        TransportObjectStore.init(control_transport.clone(OBJECTDIR))
 
350
        ret = cls(transport)
 
351
        ret.refs.set_symbolic_ref("HEAD", "refs/heads/master")
 
352
        ret._init_files(bare)
 
353
        return ret
 
354
 
335
355
 
336
356
class TransportObjectStore(PackBasedObjectStore):
337
357
    """Git-style object store that exists on disk."""