~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lockdir.py

  • Committer: Martin
  • Date: 2011-04-15 21:22:57 UTC
  • mto: This revision was merged to the branch mainline in revision 5797.
  • Revision ID: gzlist@googlemail.com-20110415212257-jgtovwwp4be7egd9
Add release notes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006-2011 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
 
        f = self.transport.get(broken_info_path)
434
 
        broken_lines = f.readlines()
 
433
        broken_content = self.transport.get_bytes(broken_info_path)
 
434
        broken_lines = osutils.split_lines(broken_content)
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
 
540
551
    def wait_lock(self, timeout=None, poll=None, max_attempts=None):
541
552
        """Wait a certain period for a lock.
542
553
 
566
577
        deadline_str = None
567
578
        last_info = None
568
579
        attempt_count = 0
 
580
        lock_url = self.lock_url_for_display()
569
581
        while True:
570
582
            attempt_count += 1
571
583
            try:
590
602
                if deadline_str is None:
591
603
                    deadline_str = time.strftime('%H:%M:%S',
592
604
                                                 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 = ''
600
605
                user, hostname, pid, time_ago = formatted_info
601
606
                msg = ('%s lock %s '        # lock_url
602
607
                    'held by '              # start