/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/revisionspec.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-22 00:56:52 UTC
  • mfrom: (6621.2.26 py3_pokes)
  • Revision ID: jelmer@jelmer.uk-20170522005652-yjahcr9hwmjkno7n
Merge Python3 porting work ('py3 pokes')

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
from __future__ import absolute_import
18
18
 
19
19
 
20
 
from breezy.lazy_import import lazy_import
 
20
from .lazy_import import lazy_import
21
21
lazy_import(globals(), """
22
22
import bisect
23
23
import datetime
32
32
from breezy.i18n import gettext
33
33
""")
34
34
 
35
 
from breezy import (
 
35
from . import (
36
36
    errors,
37
37
    lazy_regex,
38
38
    registry,
76
76
            self._has_revno = True
77
77
        return self._revno
78
78
 
79
 
    def __nonzero__(self):
 
79
    def __bool__(self):
80
80
        if self.rev_id is None:
81
81
            return False
82
82
        # TODO: otherwise, it should depend on how I was built -
84
84
        # if it's in_store(branch), do the check below
85
85
        return self.branch.repository.has_revision(self.rev_id)
86
86
 
 
87
    __nonzero__ = __bool__
 
88
 
87
89
    def __len__(self):
88
90
        return 2
89
91
 
98
100
    def __eq__(self, other):
99
101
        if type(other) not in (tuple, list, type(self)):
100
102
            return False
101
 
        if type(other) is type(self) and self.branch is not other.branch:
 
103
        if isinstance(other, type(self)) and self.branch is not other.branch:
102
104
            return False
103
105
        return tuple(self) == tuple(other)
104
106
 
422
424
                # right now - RBC 20060928
423
425
                try:
424
426
                    match_revno = tuple((int(number) for number in revno_spec.split('.')))
425
 
                except ValueError, e:
 
427
                except ValueError as e:
426
428
                    raise errors.InvalidRevisionSpec(self.user_spec, branch, e)
427
429
 
428
430
                dotted = True
533
535
 
534
536
        try:
535
537
            offset = int(self.spec)
536
 
        except ValueError, e:
 
538
        except ValueError as e:
537
539
            raise errors.InvalidRevisionSpec(self.user_spec, context_branch, e)
538
540
 
539
541
        if offset <= 0:
786
788
 
787
789
    @staticmethod
788
790
    def _find_revision_id(branch, other_location):
789
 
        from breezy.branch import Branch
 
791
        from .branch import Branch
790
792
 
791
793
        branch.lock_read()
792
794
        try:
829
831
    dwim_catchable_exceptions = (errors.NotBranchError,)
830
832
 
831
833
    def _match_on(self, branch, revs):
832
 
        from breezy.branch import Branch
 
834
        from .branch import Branch
833
835
        other_branch = Branch.open(self.spec)
834
836
        revision_b = other_branch.last_revision()
835
837
        if revision_b in (None, revision.NULL_REVISION):
845
847
        return RevisionInfo(branch, None, revision_b)
846
848
 
847
849
    def _as_revision_id(self, context_branch):
848
 
        from breezy.branch import Branch
 
850
        from .branch import Branch
849
851
        other_branch = Branch.open(self.spec)
850
852
        last_revision = other_branch.last_revision()
851
853
        last_revision = revision.ensure_null(last_revision)
855
857
        return last_revision
856
858
 
857
859
    def _as_tree(self, context_branch):
858
 
        from breezy.branch import Branch
 
860
        from .branch import Branch
859
861
        other_branch = Branch.open(self.spec)
860
862
        last_revision = other_branch.last_revision()
861
863
        last_revision = revision.ensure_null(last_revision)