~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lockdir.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-08-17 18:13:57 UTC
  • mfrom: (5268.7.29 transport-segments)
  • Revision ID: pqm@pqm.ubuntu.com-20110817181357-y5q5eth1hk8bl3om
(jelmer) Allow specifying the colocated branch to use in the branch URL,
 and retrieving the branch name using ControlDir._get_selected_branch.
 (Jelmer Vernooij)

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
 
 
103
101
 
104
102
# TODO: We sometimes have the problem that our attempt to rename '1234' to
105
103
# 'held' fails because the transport server moves into an existing directory,
109
107
# the existing locking code and needs a new format of the containing object.
110
108
# -- robertc, mbp 20070628
111
109
 
 
110
import errno
112
111
import os
113
112
import time
114
113
 
138
137
        )
139
138
from bzrlib.trace import mutter, note
140
139
from bzrlib.osutils import format_delta, rand_chars, get_host_name
141
 
from bzrlib.i18n import gettext
142
140
 
143
141
from bzrlib.lazy_import import lazy_import
144
142
lazy_import(globals(), """
318
316
            self.transport.delete(tmpname + self.__INFO_NAME)
319
317
            self.transport.rmdir(tmpname)
320
318
        except PathError, e:
321
 
            note(gettext("error removing pending lock: %s"), e)
 
319
            note("error removing pending lock: %s", e)
322
320
 
323
321
    def _create_pending_dir(self):
324
322
        tmpname = '%s/%s.tmp' % (self.path, rand_chars(10))
613
611
            new_info = self.peek()
614
612
            if new_info is not None and new_info != last_info:
615
613
                if last_info is None:
616
 
                    start = gettext('Unable to obtain')
 
614
                    start = 'Unable to obtain'
617
615
                else:
618
 
                    start = gettext('Lock owner changed for')
 
616
                    start = 'Lock owner changed for'
619
617
                last_info = new_info
620
 
                msg = gettext('{0} lock {1} {2}.').format(start, lock_url,
621
 
                                                                    new_info)
 
618
                msg = u'%s lock %s %s.' % (start, lock_url, new_info)
622
619
                if deadline_str is None:
623
620
                    deadline_str = time.strftime('%H:%M:%S',
624
621
                                                    time.localtime(deadline))
625
622
                if timeout > 0:
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.')
 
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.'
630
627
                self._report_function(msg)
631
628
            if (max_attempts is not None) and (attempt_count >= max_attempts):
632
629
                self._trace("exceeded %d attempts")
735
732
    def __unicode__(self):
736
733
        """Return a user-oriented description of this object."""
737
734
        d = self.to_readable_dict()
738
 
        return ( gettext(
 
735
        return (
739
736
            u'held by %(user)s on %(hostname)s (process #%(pid)s), '
740
 
            u'acquired %(time_ago)s') % d)
 
737
            u'acquired %(time_ago)s' % d)
741
738
 
742
739
    def to_readable_dict(self):
743
740
        """Turn the holder info into a dict of human-readable attributes.
858
855
    as it gives some clue who the user is.
859
856
    """
860
857
    try:
861
 
        return config.GlobalStack().get('email')
 
858
        return config.GlobalConfig().username()
862
859
    except errors.NoWhoami:
863
860
        return osutils.getuser_unicode()