~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lockdir.py

  • Committer: Samuel Bronson
  • Date: 2012-08-30 20:36:18 UTC
  • mto: (6015.57.3 2.4)
  • mto: This revision was merged to the branch mainline in revision 6558.
  • Revision ID: naesten@gmail.com-20120830203618-y2dzw91nqpvpgxvx
Update INSTALL for switch to Python 2.6 and up.

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(), """
297
295
        """
298
296
        if (other_holder is not None):
299
297
            if other_holder.is_lock_holder_known_dead():
300
 
                if self.get_config().get('locks.steal_dead'):
 
298
                if self.get_config().get_user_option_as_bool(
 
299
                    'locks.steal_dead',
 
300
                    default=False):
301
301
                    ui.ui_factory.show_user_warning(
302
302
                        'locks_steal_dead',
303
303
                        lock_url=urlutils.join(self.transport.base, self.path),
318
318
            self.transport.delete(tmpname + self.__INFO_NAME)
319
319
            self.transport.rmdir(tmpname)
320
320
        except PathError, e:
321
 
            note(gettext("error removing pending lock: %s"), e)
 
321
            note("error removing pending lock: %s", e)
322
322
 
323
323
    def _create_pending_dir(self):
324
324
        tmpname = '%s/%s.tmp' % (self.path, rand_chars(10))
613
613
            new_info = self.peek()
614
614
            if new_info is not None and new_info != last_info:
615
615
                if last_info is None:
616
 
                    start = gettext('Unable to obtain')
 
616
                    start = 'Unable to obtain'
617
617
                else:
618
 
                    start = gettext('Lock owner changed for')
 
618
                    start = 'Lock owner changed for'
619
619
                last_info = new_info
620
 
                msg = gettext('{0} lock {1} {2}.').format(start, lock_url,
621
 
                                                                    new_info)
 
620
                msg = u'%s lock %s %s.' % (start, lock_url, new_info)
622
621
                if deadline_str is None:
623
622
                    deadline_str = time.strftime('%H:%M:%S',
624
623
                                                    time.localtime(deadline))
625
624
                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.')
 
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.'
630
629
                self._report_function(msg)
631
630
            if (max_attempts is not None) and (attempt_count >= max_attempts):
632
631
                self._trace("exceeded %d attempts")
710
709
        """Get the configuration that governs this lockdir."""
711
710
        # XXX: This really should also use the locationconfig at least, but
712
711
        # that seems a bit hard to hook up at the moment. -- mbp 20110329
713
 
        # FIXME: The above is still true ;) -- vila 20110811
714
 
        return config.GlobalStack()
 
712
        return config.GlobalConfig()
715
713
 
716
714
 
717
715
class LockHeldInfo(object):
735
733
    def __unicode__(self):
736
734
        """Return a user-oriented description of this object."""
737
735
        d = self.to_readable_dict()
738
 
        return ( gettext(
 
736
        return (
739
737
            u'held by %(user)s on %(hostname)s (process #%(pid)s), '
740
 
            u'acquired %(time_ago)s') % d)
 
738
            u'acquired %(time_ago)s' % d)
741
739
 
742
740
    def to_readable_dict(self):
743
741
        """Turn the holder info into a dict of human-readable attributes.
858
856
    as it gives some clue who the user is.
859
857
    """
860
858
    try:
861
 
        return config.GlobalStack().get('email')
 
859
        return config.GlobalConfig().username()
862
860
    except errors.NoWhoami:
863
861
        return osutils.getuser_unicode()