~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/store.py

  • Committer: mbp at sourcefrog
  • Date: 2005-03-29 08:01:30 UTC
  • Revision ID: mbp@sourcefrog.net-20050329080130-89b78af279b196b3
match ignore patterns like ./config.h

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
 
1
#! /usr/bin/env python
 
2
# -*- coding: UTF-8 -*-
2
3
 
3
4
# This program is free software; you can redistribute it and/or modify
4
5
# it under the terms of the GNU General Public License as published by
57
58
    >>> st['123123'].read()
58
59
    'goodbye'
59
60
 
60
 
    TODO: Atomic add by writing to a temporary file and renaming.
 
61
    :todo: Atomic add by writing to a temporary file and renaming.
61
62
 
62
 
    TODO: Perhaps automatically transform to/from XML in a method?
 
63
    :todo: Perhaps automatically transform to/from XML in a method?
63
64
           Would just need to tell the constructor what class to
64
65
           use...
65
66
 
66
 
    TODO: Even within a simple disk store like this, we could
 
67
    :todo: Even within a simple disk store like this, we could
67
68
           gzip the files.  But since many are less than one disk
68
69
           block, that might not help a lot.
69
70
 
82
83
    def add(self, f, fileid, compressed=True):
83
84
        """Add contents of a file into the store.
84
85
 
85
 
        f -- An open file, or file-like object."""
 
86
        :param f: An open file, or file-like object."""
86
87
        # FIXME: Only works on smallish files
87
88
        # TODO: Can be optimized by copying at the same time as
88
89
        # computing the sum.
168
169
 
169
170
    def __del__(self):
170
171
        for f in os.listdir(self._basedir):
171
 
            fpath = os.path.join(self._basedir, f)
172
 
            # needed on windows, and maybe some other filesystems
173
 
            os.chmod(fpath, 0600)
174
 
            os.remove(fpath)
 
172
            os.remove(os.path.join(self._basedir, f))
175
173
        os.rmdir(self._basedir)
176
174
        mutter("%r destroyed" % self)