~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/atomicfile.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-05-11 11:47:36 UTC
  • mfrom: (5200.3.8 lock_return)
  • Revision ID: pqm@pqm.ubuntu.com-20100511114736-mc1sq9zyo3vufec7
(lifeless) Provide a consistent interface to Tree, Branch,
 Repository where lock methods return an object with an unlock method to
 unlock the lock. This breaks the API for Branch,
 Repository on their lock_write methods. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
from bzrlib.lazy_import import lazy_import
21
21
lazy_import(globals(), """
22
22
import stat
 
23
import socket
23
24
import warnings
24
25
 
25
26
from bzrlib import (
80
81
            if stat.S_IMODE(st.st_mode) != new_mode:
81
82
                os.chmod(self.tmpfilename, new_mode)
82
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)
 
90
 
83
91
    def __repr__(self):
84
92
        return '%s(%r)' % (self.__class__.__name__,
85
93
                           self.realfilename)
111
119
        """Discard the file unless already committed."""
112
120
        if self._fd is not None:
113
121
            self.abort()
 
122
 
 
123
    def __del__(self):
 
124
        if self._fd is not None:
 
125
            warnings.warn("%r leaked" % self)