/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 breezy/atomicfile.py

  • Committer: Jelmer Vernooij
  • Date: 2017-06-10 16:40:42 UTC
  • mfrom: (6653.6.7 rename-controldir)
  • mto: This revision was merged to the branch mainline in revision 6690.
  • Revision ID: jelmer@jelmer.uk-20170610164042-zrxqgy2htyduvke2
MergeĀ rename-controldirĀ branch.

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
17
18
 
18
19
import os
19
20
 
20
 
from bzrlib.lazy_import import lazy_import
 
21
from .lazy_import import lazy_import
21
22
lazy_import(globals(), """
22
23
import stat
23
 
import socket
24
24
import warnings
25
25
 
26
 
from bzrlib import (
 
26
from breezy import (
27
27
    errors,
28
28
    osutils,
29
 
    symbol_versioning,
30
29
    )
31
30
""")
32
31
 
68
67
        if new_mode is not None:
69
68
            local_mode = new_mode
70
69
        else:
71
 
            local_mode = 0666
 
70
            local_mode = 0o666
72
71
 
73
72
        # Use a low level fd operation to avoid chmodding later.
74
73
        # This may not succeed, but it should help most of the time
79
78
            # the common case is that we won't, though.
80
79
            st = os.fstat(self._fd)
81
80
            if stat.S_IMODE(st.st_mode) != 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)
 
81
                osutils.chmod_if_possible(self.tmpfilename, new_mode)
90
82
 
91
83
    def __repr__(self):
92
84
        return '%s(%r)' % (self.__class__.__name__,
119
111
        """Discard the file unless already committed."""
120
112
        if self._fd is not None:
121
113
            self.abort()
122
 
 
123
 
    def __del__(self):
124
 
        if self._fd is not None:
125
 
            warnings.warn("%r leaked" % self)