/breezy/unstable

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy/unstable

« back to all changes in this revision

Viewing changes to breezy/revisionspec.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-24 01:39:33 UTC
  • mfrom: (3815.3776.6)
  • Revision ID: jelmer@jelmer.uk-20170524013933-ir4y4tqtrsiz2ka2
New upstream snapshot.

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 bzrlib.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
24
24
 
25
 
from bzrlib import (
 
25
from breezy import (
26
26
    branch as _mod_branch,
27
27
    osutils,
28
28
    revision,
29
29
    symbol_versioning,
30
30
    workingtree,
31
31
    )
32
 
from bzrlib.i18n import gettext
 
32
from breezy.i18n import gettext
33
33
""")
34
34
 
35
 
from bzrlib 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
 
105
107
    def __repr__(self):
106
 
        return '<bzrlib.revisionspec.RevisionInfo object %s, %s for %r>' % (
 
108
        return '<breezy.revisionspec.RevisionInfo object %s, %s for %r>' % (
107
109
            self.revno, self.rev_id, self.branch)
108
110
 
109
111
    @staticmethod
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:
675
677
 
676
678
    One way to display all the changes since yesterday would be::
677
679
 
678
 
        bzr log -r date:yesterday..
 
680
        brz log -r date:yesterday..
679
681
 
680
682
    Examples::
681
683
 
786
788
 
787
789
    @staticmethod
788
790
    def _find_revision_id(branch, other_location):
789
 
        from bzrlib.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 bzrlib.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 bzrlib.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 bzrlib.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)