/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 bzrlib/trace.py

renamed copy_ownership to copy_ownership_from_path.
updated .bzr.log to have 0644 permissions.
improved docstring for create_log_file

Show diffs side-by-side

added added

removed removed

Lines of Context:
240
240
    global _bzr_log_filename
241
241
 
242
242
    def create_log_file(filename):
243
 
        """Create a log file in while avoiding race.
 
243
        """Create the .bzr.log file.
 
244
 
 
245
        It inherits the ownership and permissions (masked by umask) from
 
246
        the containing directory to cope better with being run under sudo
 
247
        with $HOME still set to the user's homedir.
244
248
        """
245
249
        buffering = 0 # unbuffered
246
 
        mode = os.O_WRONLY | os.O_APPEND | osutils.O_TEXT
 
250
        flags = os.O_WRONLY | os.O_APPEND | osutils.O_TEXT
247
251
        while True:
248
252
            try:
249
 
                fd = os.open(filename, mode)
 
253
                fd = os.open(filename, flags)
250
254
                logfile = os.fdopen(fd, 'at', buffering)
251
255
                return logfile
252
256
            except OSError, e:
253
257
                if e.errno != errno.ENOENT:
254
258
                    raise
255
259
            try:
256
 
                fd = os.open(filename, mode | os.O_CREAT | os.O_EXCL)
 
260
                flags = flags | os.O_CREAT | os.O_EXCL
 
261
                permissions = 0644
 
262
                fd = os.open(filename, flags, permissions)
257
263
                logfile = os.fdopen(fd, 'at', buffering)
258
264
            except OSError, e:
259
265
                if e.errno != errno.EEXIST:
260
266
                    raise
261
267
            else:
262
 
                # Copy ownership from parent directory
263
 
                osutils.copy_ownership(filename)
 
268
                osutils.copy_ownership_from_path(filename)
264
269
                return logfile
265
270
 
266
271