~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lockdir.py

  • Committer: Jelmer Vernooij
  • Date: 2012-02-20 12:19:29 UTC
  • mfrom: (6437.23.11 2.5)
  • mto: (6581.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6582.
  • Revision ID: jelmer@samba.org-20120220121929-7ni2psvjoatm1yp4
Merge bzr/2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
98
98
but helps protect against colliding host names.
99
99
"""
100
100
 
 
101
from __future__ import absolute_import
 
102
 
101
103
 
102
104
# TODO: We sometimes have the problem that our attempt to rename '1234' to
103
105
# 'held' fails because the transport server moves into an existing directory,
107
109
# the existing locking code and needs a new format of the containing object.
108
110
# -- robertc, mbp 20070628
109
111
 
110
 
import errno
111
112
import os
112
113
import time
113
114
 
137
138
        )
138
139
from bzrlib.trace import mutter, note
139
140
from bzrlib.osutils import format_delta, rand_chars, get_host_name
 
141
from bzrlib.i18n import gettext
140
142
 
141
143
from bzrlib.lazy_import import lazy_import
142
144
lazy_import(globals(), """
316
318
            self.transport.delete(tmpname + self.__INFO_NAME)
317
319
            self.transport.rmdir(tmpname)
318
320
        except PathError, e:
319
 
            note("error removing pending lock: %s", e)
 
321
            note(gettext("error removing pending lock: %s"), e)
320
322
 
321
323
    def _create_pending_dir(self):
322
324
        tmpname = '%s/%s.tmp' % (self.path, rand_chars(10))
611
613
            new_info = self.peek()
612
614
            if new_info is not None and new_info != last_info:
613
615
                if last_info is None:
614
 
                    start = 'Unable to obtain'
 
616
                    start = gettext('Unable to obtain')
615
617
                else:
616
 
                    start = 'Lock owner changed for'
 
618
                    start = gettext('Lock owner changed for')
617
619
                last_info = new_info
618
 
                msg = u'%s lock %s %s.' % (start, lock_url, new_info)
 
620
                msg = gettext('{0} lock {1} {2}.').format(start, lock_url,
 
621
                                                                    new_info)
619
622
                if deadline_str is None:
620
623
                    deadline_str = time.strftime('%H:%M:%S',
621
624
                                                    time.localtime(deadline))
622
625
                if timeout > 0:
623
 
                    msg += ('\nWill continue to try until %s, unless '
624
 
                        'you press Ctrl-C.'
625
 
                        % deadline_str)
626
 
                msg += '\nSee "bzr help break-lock" for more.'
 
626
                    msg += '\n' + gettext(
 
627
                             'Will continue to try until %s, unless '
 
628
                             'you press Ctrl-C.') % deadline_str
 
629
                msg += '\n' + gettext('See "bzr help break-lock" for more.')
627
630
                self._report_function(msg)
628
631
            if (max_attempts is not None) and (attempt_count >= max_attempts):
629
632
                self._trace("exceeded %d attempts")
732
735
    def __unicode__(self):
733
736
        """Return a user-oriented description of this object."""
734
737
        d = self.to_readable_dict()
735
 
        return (
 
738
        return ( gettext(
736
739
            u'held by %(user)s on %(hostname)s (process #%(pid)s), '
737
 
            u'acquired %(time_ago)s' % d)
 
740
            u'acquired %(time_ago)s') % d)
738
741
 
739
742
    def to_readable_dict(self):
740
743
        """Turn the holder info into a dict of human-readable attributes.