~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lockdir.py

  • Committer: John Arbash Meinel
  • Date: 2009-12-02 17:49:45 UTC
  • mto: This revision was merged to the branch mainline in revision 4854.
  • Revision ID: john@arbash-meinel.com-20091202174945-80ack0gu7j8j8mqm
Change the LockDir code to use get_bytes rather than get().

If we are always going to read all the bytes anyway, this is better for
apis. Also, get_bytes() always closes the file handle in a finally block,
rather than doing it asynchronously through the deconstructors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2008 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2008, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
110
110
    debug,
111
111
    errors,
112
112
    lock,
 
113
    osutils,
113
114
    )
114
115
import bzrlib.config
115
116
from bzrlib.decorators import only_raises
416
417
 
417
418
        peek() reads the info file of the lock holder, if any.
418
419
        """
419
 
        return self._parse_info(self.transport.get(path))
 
420
        return self._parse_info(self.transport.get_bytes(path))
420
421
 
421
422
    def peek(self):
422
423
        """Check if the lock is held by anyone.
449
450
                   )
450
451
        return s.to_string()
451
452
 
452
 
    def _parse_info(self, info_file):
453
 
        return rio.read_stanza(info_file.readlines()).as_dict()
 
453
    def _parse_info(self, info_bytes):
 
454
        # TODO: Handle if info_bytes is empty
 
455
        return rio.read_stanza(osutils.split_lines(info_bytes)).as_dict()
454
456
 
455
457
    def attempt_lock(self):
456
458
        """Take the lock; fail if it's already held.