~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lockdir.py

  • Committer: John Arbash Meinel
  • Date: 2006-09-09 00:52:19 UTC
  • mto: This revision was merged to the branch mainline in revision 1998.
  • Revision ID: john@arbash-meinel.com-20060909005219-eee5bd7a64aa0256
Use Stanza.to_string() rather than a RioWriter

Show diffs side-by-side

added added

removed removed

Lines of Context:
114
114
from bzrlib.trace import mutter
115
115
from bzrlib.transport import Transport
116
116
from bzrlib.osutils import rand_chars
117
 
from bzrlib.rio import RioWriter, read_stanza, Stanza
 
117
from bzrlib.rio import read_stanza, Stanza
118
118
 
119
119
# XXX: At the moment there is no consideration of thread safety on LockDir
120
120
# objects.  This should perhaps be updated - e.g. if two threads try to take a
200
200
                # After creating the lock directory, try again
201
201
                self.transport.mkdir(tmpname)
202
202
 
203
 
            sio = StringIO()
204
 
            self._prepare_info(sio)
205
 
            sio.seek(0)
 
203
            info_bytes = self._prepare_info()
206
204
            # We use put_file_non_atomic because we just created a new unique
207
205
            # directory so we don't have to worry about files existing there.
208
206
            # We'll rename the whole directory into place to get atomic
209
207
            # properties
210
 
            self.transport.put_file_non_atomic(tmpname + self.__INFO_NAME, sio)
 
208
            self.transport.put_bytes_non_atomic(tmpname + self.__INFO_NAME,
 
209
                                                info_bytes)
211
210
 
212
211
            self.transport.rename(tmpname, self._held_dir)
213
212
            self._lock_held = True
336
335
        except NoSuchFile, e:
337
336
            return None
338
337
 
339
 
    def _prepare_info(self, outf):
 
338
    def _prepare_info(self):
340
339
        """Write information about a pending lock to a temporary file.
341
340
        """
342
341
        import socket
348
347
                   nonce=self.nonce,
349
348
                   user=config.user_email(),
350
349
                   )
351
 
        RioWriter(outf).write_stanza(s)
 
350
        return s.to_string()
352
351
 
353
352
    def _parse_info(self, info_file):
354
353
        return read_stanza(info_file.readlines()).as_dict()