~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lockdir.py

(gz) Change minimum required testtools version for selftest to 0.9.5 for
 unicode fixes (Martin [gz])

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2011 Canonical Ltd
 
1
# Copyright (C) 2006-2010 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
430
430
        # there's a small race window between checking it and doing the
431
431
        # rename.
432
432
        broken_info_path = tmpname + self.__INFO_NAME
433
 
        broken_content = self.transport.get_bytes(broken_info_path)
434
 
        broken_lines = osutils.split_lines(broken_content)
 
433
        f = self.transport.get(broken_info_path)
 
434
        broken_lines = f.readlines()
435
435
        if broken_lines != corrupt_info_lines:
436
436
            raise LockBreakMismatch(self, broken_lines, corrupt_info_lines)
437
437
        self.transport.delete(broken_info_path)
537
537
            hook(hook_result)
538
538
        return result
539
539
 
540
 
    def lock_url_for_display(self):
541
 
        """Give a nicely-printable representation of the URL of this lock."""
542
 
        # As local lock urls are correct we display them.
543
 
        # We avoid displaying remote lock urls.
544
 
        lock_url = self.transport.abspath(self.path)
545
 
        if lock_url.startswith('file://'):
546
 
            lock_url = lock_url.split('.bzr/')[0]
547
 
        else:
548
 
            lock_url = ''
549
 
        return lock_url
550
 
 
551
540
    def wait_lock(self, timeout=None, poll=None, max_attempts=None):
552
541
        """Wait a certain period for a lock.
553
542
 
577
566
        deadline_str = None
578
567
        last_info = None
579
568
        attempt_count = 0
580
 
        lock_url = self.lock_url_for_display()
581
569
        while True:
582
570
            attempt_count += 1
583
571
            try:
602
590
                if deadline_str is None:
603
591
                    deadline_str = time.strftime('%H:%M:%S',
604
592
                                                 time.localtime(deadline))
 
593
                # As local lock urls are correct we display them.
 
594
                # We avoid displaying remote lock urls.
 
595
                lock_url = self.transport.abspath(self.path)
 
596
                if lock_url.startswith('file://'):
 
597
                    lock_url = lock_url.split('.bzr/')[0]
 
598
                else:
 
599
                    lock_url = ''
605
600
                user, hostname, pid, time_ago = formatted_info
606
601
                msg = ('%s lock %s '        # lock_url
607
602
                    'held by '              # start