~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lockdir.py

  • Committer: Martin Pool
  • Date: 2011-03-31 09:01:27 UTC
  • mto: (5609.29.2 2.3)
  • mto: This revision was merged to the branch mainline in revision 5755.
  • Revision ID: mbp@canonical.com-20110331090127-w6wqfh5kseeqjg0f
Avoid UnboundLocalError reporting url when wait_lock fails

Show diffs side-by-side

added added

removed removed

Lines of Context:
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