/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/lockdir.py

  • Committer: Jelmer Vernooij
  • Date: 2017-07-23 22:06:41 UTC
  • mfrom: (6738 trunk)
  • mto: This revision was merged to the branch mainline in revision 6739.
  • Revision ID: jelmer@jelmer.uk-20170723220641-69eczax9bmv8d6kk
Merge trunk, address review comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
136
136
        ResourceBusy,
137
137
        TransportError,
138
138
        )
 
139
from .i18n import gettext
 
140
from .osutils import format_delta, rand_chars, get_host_name
 
141
from .sixish import (
 
142
    PY3,
 
143
    text_type,
 
144
    )
139
145
from .trace import mutter, note
140
 
from .osutils import format_delta, rand_chars, get_host_name
141
 
from .i18n import gettext
142
146
 
143
147
from .lazy_import import lazy_import
144
148
lazy_import(globals(), """
301
305
                    ui.ui_factory.show_user_warning(
302
306
                        'locks_steal_dead',
303
307
                        lock_url=urlutils.join(self.transport.base, self.path),
304
 
                        other_holder_info=unicode(other_holder))
 
308
                        other_holder_info=text_type(other_holder))
305
309
                    self.force_break(other_holder)
306
310
                    self._trace("stole lock from dead holder")
307
311
                    return
408
412
            if ui.ui_factory.confirm_action(
409
413
                u"Break %(lock_info)s",
410
414
                'breezy.lockdir.break',
411
 
                dict(lock_info=unicode(holder_info))):
 
415
                dict(lock_info=text_type(holder_info))):
412
416
                result = self.force_break(holder_info)
413
417
                ui.ui_factory.show_message(
414
418
                    "Broke lock %s" % result.lock_url)
739
743
            u'held by %(user)s on %(hostname)s (process #%(pid)s), '
740
744
            u'acquired %(time_ago)s') % d)
741
745
 
 
746
    if PY3:
 
747
        __str__ = __unicode__
 
748
 
742
749
    def to_readable_dict(self):
743
750
        """Turn the holder info into a dict of human-readable attributes.
744
751
 
804
811
        else:
805
812
            return cls(stanza.as_dict())
806
813
 
807
 
    def __cmp__(self, other):
808
 
        """Value comparison of lock holders."""
809
 
        return (
810
 
            cmp(type(self), type(other))
811
 
            or cmp(self.info_dict, other.info_dict))
 
814
    def __hash__(self):
 
815
        return id(self)
 
816
 
 
817
    def __eq__(self, other):
 
818
        """Equality check for lock holders."""
 
819
        if type(self) != type(other):
 
820
            return False
 
821
        return self.info_dict == other.info_dict
 
822
 
 
823
    def __ne__(self, other):
 
824
        return not self == other
812
825
 
813
826
    def is_locked_by_this_process(self):
814
827
        """True if this process seems to be the current lock holder."""
859
872
    """
860
873
    try:
861
874
        return config.GlobalStack().get('email')
862
 
    except errors.NoWhoami:
 
875
    except config.NoWhoami:
863
876
        return osutils.getuser_unicode()