~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lockdir.py

  • Committer: Gordon Tyler
  • Date: 2010-01-14 15:24:04 UTC
  • mto: (5037.3.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5046.
  • Revision ID: gordon@doxxx.net-20100114152404-d64ik2afl96lcml0
Reverted changes to test_rules since the original should work now.

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
 
116
from bzrlib.decorators import only_raises
115
117
from bzrlib.errors import (
116
118
        DirectoryNotEmpty,
117
119
        FileExists,
286
288
                                            info_bytes)
287
289
        return tmpname
288
290
 
 
291
    @only_raises(LockNotHeld, LockBroken)
289
292
    def unlock(self):
290
293
        """Release a held lock
291
294
        """
414
417
 
415
418
        peek() reads the info file of the lock holder, if any.
416
419
        """
417
 
        return self._parse_info(self.transport.get(path))
 
420
        return self._parse_info(self.transport.get_bytes(path))
418
421
 
419
422
    def peek(self):
420
423
        """Check if the lock is held by anyone.
447
450
                   )
448
451
        return s.to_string()
449
452
 
450
 
    def _parse_info(self, info_file):
451
 
        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()
452
456
 
453
457
    def attempt_lock(self):
454
458
        """Take the lock; fail if it's already held.