~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lockdir.py

  • Committer: Vincent Ladeuil
  • Date: 2011-11-24 15:48:29 UTC
  • mfrom: (6289 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6337.
  • Revision ID: v.ladeuil+lp@free.fr-20111124154829-avowjpsxdl8yp2vz
merge trunk resolving conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
137
137
        )
138
138
from bzrlib.trace import mutter, note
139
139
from bzrlib.osutils import format_delta, rand_chars, get_host_name
 
140
from bzrlib.i18n import gettext
140
141
 
141
142
from bzrlib.lazy_import import lazy_import
142
143
lazy_import(globals(), """
295
296
        """
296
297
        if (other_holder is not None):
297
298
            if other_holder.is_lock_holder_known_dead():
298
 
                if self.get_config().get_user_option_as_bool(
299
 
                    'locks.steal_dead',
300
 
                    default=False):
 
299
                if self.get_config().get('locks.steal_dead'):
301
300
                    ui.ui_factory.show_user_warning(
302
301
                        'locks_steal_dead',
303
302
                        lock_url=urlutils.join(self.transport.base, self.path),
318
317
            self.transport.delete(tmpname + self.__INFO_NAME)
319
318
            self.transport.rmdir(tmpname)
320
319
        except PathError, e:
321
 
            note("error removing pending lock: %s", e)
 
320
            note(gettext("error removing pending lock: %s"), e)
322
321
 
323
322
    def _create_pending_dir(self):
324
323
        tmpname = '%s/%s.tmp' % (self.path, rand_chars(10))
613
612
            new_info = self.peek()
614
613
            if new_info is not None and new_info != last_info:
615
614
                if last_info is None:
616
 
                    start = 'Unable to obtain'
 
615
                    start = gettext('Unable to obtain')
617
616
                else:
618
 
                    start = 'Lock owner changed for'
 
617
                    start = gettext('Lock owner changed for')
619
618
                last_info = new_info
620
 
                msg = u'%s lock %s %s.' % (start, lock_url, new_info)
 
619
                msg = gettext('{0} lock {1} {2}.').format(start, lock_url,
 
620
                                                                    new_info)
621
621
                if deadline_str is None:
622
622
                    deadline_str = time.strftime('%H:%M:%S',
623
623
                                                    time.localtime(deadline))
624
624
                if timeout > 0:
625
 
                    msg += ('\nWill continue to try until %s, unless '
626
 
                        'you press Ctrl-C.'
627
 
                        % deadline_str)
628
 
                msg += '\nSee "bzr help break-lock" for more.'
 
625
                    msg += '\n' + gettext(
 
626
                             'Will continue to try until %s, unless '
 
627
                             'you press Ctrl-C.') % deadline_str
 
628
                msg += '\n' + gettext('See "bzr help break-lock" for more.')
629
629
                self._report_function(msg)
630
630
            if (max_attempts is not None) and (attempt_count >= max_attempts):
631
631
                self._trace("exceeded %d attempts")
709
709
        """Get the configuration that governs this lockdir."""
710
710
        # XXX: This really should also use the locationconfig at least, but
711
711
        # that seems a bit hard to hook up at the moment. -- mbp 20110329
712
 
        return config.GlobalConfig()
 
712
        # FIXME: The above is still true ;) -- vila 20110811
 
713
        return config.GlobalStack()
713
714
 
714
715
 
715
716
class LockHeldInfo(object):
733
734
    def __unicode__(self):
734
735
        """Return a user-oriented description of this object."""
735
736
        d = self.to_readable_dict()
736
 
        return (
 
737
        return ( gettext(
737
738
            u'held by %(user)s on %(hostname)s (process #%(pid)s), '
738
 
            u'acquired %(time_ago)s' % d)
 
739
            u'acquired %(time_ago)s') % d)
739
740
 
740
741
    def to_readable_dict(self):
741
742
        """Turn the holder info into a dict of human-readable attributes.