~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/atomicfile.py

  • Committer: Vincent Ladeuil
  • Date: 2010-12-07 10:16:53 UTC
  • mto: (5575.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 5576.
  • Revision ID: v.ladeuil+lp@free.fr-20101207101653-20iiufih26buvmy3
Use assertLength as it provides a better ouput to debug tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
from __future__ import absolute_import
18
17
 
19
18
import os
20
19
 
21
20
from bzrlib.lazy_import import lazy_import
22
21
lazy_import(globals(), """
23
22
import stat
 
23
import socket
24
24
import warnings
25
25
 
26
26
from bzrlib import (
79
79
            # the common case is that we won't, though.
80
80
            st = os.fstat(self._fd)
81
81
            if stat.S_IMODE(st.st_mode) != new_mode:
82
 
                osutils.chmod_if_possible(self.tmpfilename, new_mode)
 
82
                os.chmod(self.tmpfilename, new_mode)
 
83
 
 
84
    def _get_closed(self):
 
85
        symbol_versioning.warn('AtomicFile.closed deprecated in bzr 0.10',
 
86
                               DeprecationWarning, stacklevel=2)
 
87
        return self._fd is None
 
88
 
 
89
    closed = property(_get_closed)
83
90
 
84
91
    def __repr__(self):
85
92
        return '%s(%r)' % (self.__class__.__name__,
112
119
        """Discard the file unless already committed."""
113
120
        if self._fd is not None:
114
121
            self.abort()
 
122
 
 
123
    def __del__(self):
 
124
        if self._fd is not None:
 
125
            warnings.warn("%r leaked" % self)