/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
4763.2.4 by John Arbash Meinel
merge bzr.2.1 in preparation for NEWS entry.
1
# Copyright (C) 2005-2010 Canonical Ltd
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
2
#
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
7
#
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
12
#
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
16
17
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
18
from .lazy_import import lazy_import
3224.5.31 by Andrew Bennetts
A couple more lazy imports, helps 'bzr log --line -r -1' a little.
19
lazy_import(globals(), """
1948.4.1 by John Arbash Meinel
Update number parsers to raise InvalidRevisionSpec. Update revno: itself so it supports negative numbers
20
import bisect
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
21
import datetime
5671.1.2 by Jelmer Vernooij
Lazy load gzip (we don't use it when doing 2a), remove some unused imports.
22
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
23
from breezy import (
5365.6.4 by Aaron Bentley
Implement mainline revision spec.
24
    branch as _mod_branch,
6630.1.1 by Jelmer Vernooij
Remove deprecated functionality.
25
    cache_utf8,
1948.4.18 by John Arbash Meinel
Update branch: spec and tests
26
    revision,
5685.1.1 by Jelmer Vernooij
More lazy imports, lazy regexes in bzrlib.revisionspec.
27
    workingtree,
28
    )
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
29
from breezy.i18n import gettext
5685.1.1 by Jelmer Vernooij
More lazy imports, lazy regexes in bzrlib.revisionspec.
30
""")
31
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
32
from . import (
5685.1.1 by Jelmer Vernooij
More lazy imports, lazy regexes in bzrlib.revisionspec.
33
    errors,
5685.1.2 by Jelmer Vernooij
Merge bzr.dev.
34
    lazy_regex,
5685.1.1 by Jelmer Vernooij
More lazy imports, lazy regexes in bzrlib.revisionspec.
35
    registry,
1948.4.27 by John Arbash Meinel
Deprecate calling RevisionSpec directly, and instead use a helper function. Also merge the old RevisionSpec_int class into RevisionSpec_revno
36
    trace,
1948.4.1 by John Arbash Meinel
Update number parsers to raise InvalidRevisionSpec. Update revno: itself so it supports negative numbers
37
    )
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
38
1948.4.16 by John Arbash Meinel
Move the tests into the associated tester, remove redundant tests, some small PEP8 changes
39
7499.1.1 by Jelmer Vernooij
Move InvalidRevisionSpec to breezy.revisionspec.
40
class InvalidRevisionSpec(errors.BzrError):
41
42
    _fmt = ("Requested revision: '%(spec)s' does not exist in branch:"
43
            " %(branch_url)s%(extra)s")
44
45
    def __init__(self, spec, branch, extra=None):
46
        errors.BzrError.__init__(self, branch=branch, spec=spec)
47
        self.branch_url = getattr(branch, 'user_url', str(branch))
48
        if extra:
49
            self.extra = '\n' + str(extra)
50
        else:
51
            self.extra = ''
52
53
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
54
class RevisionInfo(object):
2070.4.14 by John Arbash Meinel
Switch revisionspec to use the help defined as help_txt rather than the doc string
55
    """The results of applying a revision specification to a branch."""
56
57
    help_txt = """The results of applying a revision specification to a branch.
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
58
59
    An instance has two useful attributes: revno, and rev_id.
60
61
    They can also be accessed as spec[0] and spec[1] respectively,
62
    so that you can write code like:
63
    revno, rev_id = RevisionSpec(branch, spec)
64
    although this is probably going to be deprecated later.
65
66
    This class exists mostly to be the return value of a RevisionSpec,
67
    so that you can access the member you're interested in (number or id)
68
    or treat the result as a tuple.
69
    """
70
6336.1.1 by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it.
71
    def __init__(self, branch, revno=None, rev_id=None):
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
72
        self.branch = branch
6336.1.1 by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it.
73
        self._has_revno = (revno is not None)
74
        self._revno = revno
75
        self.rev_id = rev_id
76
        if self.rev_id is None and self._revno is not None:
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
77
            # allow caller to be lazy
6336.1.1 by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it.
78
            self.rev_id = branch.get_rev_id(self._revno)
79
80
    @property
81
    def revno(self):
82
        if not self._has_revno and self.rev_id is not None:
83
            try:
84
                self._revno = self.branch.revision_id_to_revno(self.rev_id)
7290.19.7 by Jelmer Vernooij
Catch RevnoOutOfBounds.
85
            except (errors.NoSuchRevision, errors.RevnoOutOfBounds):
6336.1.1 by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it.
86
                self._revno = None
87
            self._has_revno = True
88
        return self._revno
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
89
6619.3.20 by Jelmer Vernooij
Apply 2to3 nonzero fix.
90
    def __bool__(self):
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
91
        if self.rev_id is None:
92
            return False
93
        # TODO: otherwise, it should depend on how I was built -
94
        # if it's in_history(branch), then check revision_history(),
95
        # if it's in_store(branch), do the check below
1185.67.2 by Aaron Bentley
Renamed Branch.storage to Branch.repository
96
        return self.branch.repository.has_revision(self.rev_id)
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
97
6619.3.23 by Jelmer Vernooij
Keep __nonzero__ around for Python2.
98
    __nonzero__ = __bool__
99
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
100
    def __len__(self):
101
        return 2
102
103
    def __getitem__(self, index):
7143.15.2 by Jelmer Vernooij
Run autopep8.
104
        if index == 0:
105
            return self.revno
106
        if index == 1:
107
            return self.rev_id
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
108
        raise IndexError(index)
109
110
    def get(self):
1185.67.2 by Aaron Bentley
Renamed Branch.storage to Branch.repository
111
        return self.branch.repository.get_revision(self.rev_id)
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
112
113
    def __eq__(self, other):
114
        if type(other) not in (tuple, list, type(self)):
115
            return False
6619.3.18 by Jelmer Vernooij
Run 2to3 idioms fixer.
116
        if isinstance(other, type(self)) and self.branch is not other.branch:
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
117
            return False
118
        return tuple(self) == tuple(other)
119
120
    def __repr__(self):
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
121
        return '<breezy.revisionspec.RevisionInfo object %s, %s for %r>' % (
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
122
            self.revno, self.rev_id, self.branch)
123
2220.2.3 by Martin Pool
Add tag: revision namespace.
124
    @staticmethod
6630.1.1 by Jelmer Vernooij
Remove deprecated functionality.
125
    def from_revision_id(branch, revision_id):
2220.2.3 by Martin Pool
Add tag: revision namespace.
126
        """Construct a RevisionInfo given just the id.
127
128
        Use this if you don't know or care what the revno is.
129
        """
6336.1.1 by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it.
130
        return RevisionInfo(branch, revno=None, rev_id=revision_id)
2220.2.3 by Martin Pool
Add tag: revision namespace.
131
1948.4.16 by John Arbash Meinel
Move the tests into the associated tester, remove redundant tests, some small PEP8 changes
132
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
133
class RevisionSpec(object):
2070.4.14 by John Arbash Meinel
Switch revisionspec to use the help defined as help_txt rather than the doc string
134
    """A parsed revision specification."""
135
136
    help_txt = """A parsed revision specification.
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
137
4569.2.3 by Matthew Fuller
Adjust the help test for the RevisionSpec class a bit to describe the
138
    A revision specification is a string, which may be unambiguous about
139
    what it represents by giving a prefix like 'date:' or 'revid:' etc,
140
    or it may have no prefix, in which case it's tried against several
141
    specifier types in sequence to determine what the user meant.
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
142
143
    Revision specs are an UI element, and they have been moved out
144
    of the branch class to leave "back-end" classes unaware of such
145
    details.  Code that gets a revno or rev_id from other code should
146
    not be using revision specs - revnos and revision ids are the
147
    accepted ways to refer to revisions internally.
148
149
    (Equivalent to the old Branch method get_revision_info())
150
    """
151
152
    prefix = None
7499.1.1 by Jelmer Vernooij
Move InvalidRevisionSpec to breezy.revisionspec.
153
    dwim_catchable_exceptions = (InvalidRevisionSpec,)
4569.2.21 by Vincent Ladeuil
Fix some typos.
154
    """Exceptions that RevisionSpec_dwim._match_on will catch.
4569.2.18 by Vincent Ladeuil
Small refactoring to unblock the submission.
155
4569.2.21 by Vincent Ladeuil
Fix some typos.
156
    If the revspec is part of ``dwim_revspecs``, it may be tried with an
157
    invalid revspec and raises some exception. The exceptions mentioned here
158
    will not be reported to the user but simply ignored without stopping the
159
    dwim processing.
4569.2.18 by Vincent Ladeuil
Small refactoring to unblock the submission.
160
    """
1948.4.33 by John Arbash Meinel
Switch from get_revision_spec() to RevisionSpec.from_string() (as advised by Martin)
161
162
    @staticmethod
163
    def from_string(spec):
164
        """Parse a revision spec string into a RevisionSpec object.
165
166
        :param spec: A string specified by the user
167
        :return: A RevisionSpec object that understands how to parse the
168
            supplied notation.
169
        """
170
        if spec is None:
171
            return RevisionSpec(None, _internal=True)
7479.2.1 by Jelmer Vernooij
Drop python2 support.
172
        if not isinstance(spec, str):
6695.3.2 by Martin
Fix test fallout from basestring removal
173
            raise TypeError("revision spec needs to be text")
3966.2.1 by Jelmer Vernooij
Register revision specifiers in a registry.
174
        match = revspec_registry.get_prefix(spec)
175
        if match is not None:
176
            spectype, specsuffix = match
177
            trace.mutter('Returning RevisionSpec %s for %s',
178
                         spectype.__name__, spec)
179
            return spectype(spec, _internal=True)
1948.4.33 by John Arbash Meinel
Switch from get_revision_spec() to RevisionSpec.from_string() (as advised by Martin)
180
        else:
4569.2.18 by Vincent Ladeuil
Small refactoring to unblock the submission.
181
            # Otherwise treat it as a DWIM, build the RevisionSpec object and
182
            # wait for _match_on to be called.
4569.2.1 by Matthew Fuller
Implement a DWIM revspec type and use it to allow simpler user
183
            return RevisionSpec_dwim(spec, _internal=True)
1948.4.27 by John Arbash Meinel
Deprecate calling RevisionSpec directly, and instead use a helper function. Also merge the old RevisionSpec_int class into RevisionSpec_revno
184
185
    def __init__(self, spec, _internal=False):
186
        """Create a RevisionSpec referring to the Null revision.
187
188
        :param spec: The original spec supplied by the user
189
        :param _internal: Used to ensure that RevisionSpec is not being
1948.4.33 by John Arbash Meinel
Switch from get_revision_spec() to RevisionSpec.from_string() (as advised by Martin)
190
            called directly. Only from RevisionSpec.from_string()
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
191
        """
1948.4.27 by John Arbash Meinel
Deprecate calling RevisionSpec directly, and instead use a helper function. Also merge the old RevisionSpec_int class into RevisionSpec_revno
192
        if not _internal:
6630.1.1 by Jelmer Vernooij
Remove deprecated functionality.
193
            raise AssertionError(
194
                'Creating a RevisionSpec directly is not supported. '
195
                'Use RevisionSpec.from_string() instead.')
1948.4.27 by John Arbash Meinel
Deprecate calling RevisionSpec directly, and instead use a helper function. Also merge the old RevisionSpec_int class into RevisionSpec_revno
196
        self.user_spec = spec
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
197
        if self.prefix and spec.startswith(self.prefix):
198
            spec = spec[len(self.prefix):]
199
        self.spec = spec
200
201
    def _match_on(self, branch, revs):
1948.4.27 by John Arbash Meinel
Deprecate calling RevisionSpec directly, and instead use a helper function. Also merge the old RevisionSpec_int class into RevisionSpec_revno
202
        trace.mutter('Returning RevisionSpec._match_on: None')
3298.2.11 by Aaron Bentley
Update tests for null:, clea up slightly
203
        return RevisionInfo(branch, None, None)
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
204
205
    def _match_on_and_check(self, branch, revs):
206
        info = self._match_on(branch, revs)
207
        if info:
208
            return info
3298.2.11 by Aaron Bentley
Update tests for null:, clea up slightly
209
        elif info == (None, None):
210
            # special case - nothing supplied
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
211
            return info
212
        elif self.prefix:
7499.1.1 by Jelmer Vernooij
Move InvalidRevisionSpec to breezy.revisionspec.
213
            raise InvalidRevisionSpec(self.user_spec, branch)
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
214
        else:
7499.1.1 by Jelmer Vernooij
Move InvalidRevisionSpec to breezy.revisionspec.
215
            raise InvalidRevisionSpec(self.spec, branch)
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
216
217
    def in_history(self, branch):
6630.1.1 by Jelmer Vernooij
Remove deprecated functionality.
218
        return self._match_on_and_check(branch, revs=None)
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
219
1432 by Robert Collins
branch: namespace
220
        # FIXME: in_history is somewhat broken,
221
        # it will return non-history revisions in many
222
        # circumstances. The expected facility is that
223
        # in_history only returns revision-history revs,
224
        # in_store returns any rev. RBC 20051010
225
    # aliases for now, when we fix the core logic, then they
226
    # will do what you expect.
227
    in_store = in_history
3298.2.8 by John Arbash Meinel
Get rid of .in_branch(need_revno=False) in favor of simpler .as_revision_id()
228
    in_branch = in_store
3060.3.2 by Lukáš Lalinský
Make RevisionSpec_last not load the whole history.
229
3298.2.4 by John Arbash Meinel
Introduce as_revision_id() as a function instead of in_branch(need_revno=False)
230
    def as_revision_id(self, context_branch):
231
        """Return just the revision_id for this revisions spec.
232
233
        Some revision specs require a context_branch to be able to determine
234
        their value. Not all specs will make use of it.
235
        """
236
        return self._as_revision_id(context_branch)
237
238
    def _as_revision_id(self, context_branch):
239
        """Implementation of as_revision_id()
240
241
        Classes should override this function to provide appropriate
242
        functionality. The default is to just call '.in_history().rev_id'
243
        """
244
        return self.in_history(context_branch).rev_id
245
3655.3.1 by Lukáš Lalinský
Fix `bzr st -rbranch:PATH_TO_BRANCH`
246
    def as_tree(self, context_branch):
247
        """Return the tree object for this revisions spec.
248
249
        Some revision specs require a context_branch to be able to determine
250
        the revision id and access the repository. Not all specs will make
251
        use of it.
252
        """
253
        return self._as_tree(context_branch)
254
255
    def _as_tree(self, context_branch):
3732.1.1 by Ian Clatworthy
fix bzr st -rbranch:path-to-branch (Lukas Lalinsky)
256
        """Implementation of as_tree().
3655.3.1 by Lukáš Lalinský
Fix `bzr st -rbranch:PATH_TO_BRANCH`
257
258
        Classes should override this function to provide appropriate
259
        functionality. The default is to just call '.as_revision_id()'
260
        and get the revision tree from context_branch's repository.
261
        """
262
        revision_id = self.as_revision_id(context_branch)
263
        return context_branch.repository.revision_tree(revision_id)
264
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
265
    def __repr__(self):
266
        # this is mostly for helping with testing
1948.4.32 by John Arbash Meinel
Clean up __repr__, as well as add tests that we can handle -r12:branch/
267
        return '<%s %s>' % (self.__class__.__name__,
7143.15.2 by Jelmer Vernooij
Run autopep8.
268
                            self.user_spec)
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
269
1881.1.4 by Matthieu Moy
needs_tree -> needs_branch
270
    def needs_branch(self):
271
        """Whether this revision spec needs a branch.
272
1711.2.99 by John Arbash Meinel
minor typo fix
273
        Set this to False the branch argument of _match_on is not used.
274
        """
1881.1.1 by Matthieu Moy
Fixed and tested "bzr diff" outside a working tree.
275
        return True
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
276
1907.4.1 by Matthieu Moy
Fixed merge to work nicely with -r revno:N:path
277
    def get_branch(self):
278
        """When the revision specifier contains a branch location, return it.
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
279
1907.4.1 by Matthieu Moy
Fixed merge to work nicely with -r revno:N:path
280
        Otherwise, return None.
281
        """
282
        return None
283
1907.4.9 by Matthieu Moy
missing newline
284
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
285
# private API
286
4569.2.1 by Matthew Fuller
Implement a DWIM revspec type and use it to allow simpler user
287
class RevisionSpec_dwim(RevisionSpec):
288
    """Provides a DWIMish revision specifier lookup.
289
4569.2.18 by Vincent Ladeuil
Small refactoring to unblock the submission.
290
    Note that this does not go in the revspec_registry because by definition
291
    there is no prefix to identify it.  It's solely called from
292
    RevisionSpec.from_string() because the DWIMification happen when _match_on
293
    is called so the string describing the revision is kept here until needed.
4569.2.1 by Matthew Fuller
Implement a DWIM revspec type and use it to allow simpler user
294
    """
295
296
    help_txt = None
297
5685.1.1 by Jelmer Vernooij
More lazy imports, lazy regexes in bzrlib.revisionspec.
298
    _revno_regex = lazy_regex.lazy_compile(r'^(?:(\d+(\.\d+)*)|-\d+)(:.*)?$')
299
5671.5.1 by Jelmer Vernooij
Allow lazily registering possible DWIM revspecs.
300
    # The revspecs to try
301
    _possible_revspecs = []
302
4569.2.19 by Vincent Ladeuil
A bit more tweaks.
303
    def _try_spectype(self, rstype, branch):
304
        rs = rstype(self.spec, _internal=True)
4569.2.1 by Matthew Fuller
Implement a DWIM revspec type and use it to allow simpler user
305
        # Hit in_history to find out if it exists, or we need to try the
306
        # next type.
307
        return rs.in_history(branch)
308
309
    def _match_on(self, branch, revs):
310
        """Run the lookup and see what we can get."""
311
312
        # First, see if it's a revno
5685.1.1 by Jelmer Vernooij
More lazy imports, lazy regexes in bzrlib.revisionspec.
313
        if self._revno_regex.match(self.spec) is not None:
4569.2.1 by Matthew Fuller
Implement a DWIM revspec type and use it to allow simpler user
314
            try:
4569.2.19 by Vincent Ladeuil
A bit more tweaks.
315
                return self._try_spectype(RevisionSpec_revno, branch)
4569.2.18 by Vincent Ladeuil
Small refactoring to unblock the submission.
316
            except RevisionSpec_revno.dwim_catchable_exceptions:
317
                pass
318
319
        # Next see what has been registered
5671.5.1 by Jelmer Vernooij
Allow lazily registering possible DWIM revspecs.
320
        for objgetter in self._possible_revspecs:
321
            rs_class = objgetter.get_obj()
322
            try:
323
                return self._try_spectype(rs_class, branch)
324
            except rs_class.dwim_catchable_exceptions:
325
                pass
326
4569.2.18 by Vincent Ladeuil
Small refactoring to unblock the submission.
327
        # Well, I dunno what it is. Note that we don't try to keep track of the
328
        # first of last exception raised during the DWIM tries as none seems
329
        # really relevant.
7499.1.1 by Jelmer Vernooij
Move InvalidRevisionSpec to breezy.revisionspec.
330
        raise InvalidRevisionSpec(self.spec, branch)
4569.2.1 by Matthew Fuller
Implement a DWIM revspec type and use it to allow simpler user
331
5671.5.3 by Jelmer Vernooij
Fix test.. not sure how I missed this.
332
    @classmethod
333
    def append_possible_revspec(cls, revspec):
5671.5.1 by Jelmer Vernooij
Allow lazily registering possible DWIM revspecs.
334
        """Append a possible DWIM revspec.
335
336
        :param revspec: Revision spec to try.
337
        """
5671.5.3 by Jelmer Vernooij
Fix test.. not sure how I missed this.
338
        cls._possible_revspecs.append(registry._ObjectGetter(revspec))
5671.5.1 by Jelmer Vernooij
Allow lazily registering possible DWIM revspecs.
339
5671.5.3 by Jelmer Vernooij
Fix test.. not sure how I missed this.
340
    @classmethod
341
    def append_possible_lazy_revspec(cls, module_name, member_name):
5671.5.1 by Jelmer Vernooij
Allow lazily registering possible DWIM revspecs.
342
        """Append a possible lazily loaded DWIM revspec.
343
344
        :param module_name: Name of the module with the revspec
345
        :param member_name: Name of the revspec within the module
346
        """
5671.5.3 by Jelmer Vernooij
Fix test.. not sure how I missed this.
347
        cls._possible_revspecs.append(
5671.5.1 by Jelmer Vernooij
Allow lazily registering possible DWIM revspecs.
348
            registry._LazyObjectGetter(module_name, member_name))
349
4569.2.1 by Matthew Fuller
Implement a DWIM revspec type and use it to allow simpler user
350
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
351
class RevisionSpec_revno(RevisionSpec):
2070.4.14 by John Arbash Meinel
Switch revisionspec to use the help defined as help_txt rather than the doc string
352
    """Selects a revision using a number."""
353
354
    help_txt = """Selects a revision using a number.
2023.1.1 by ghigo
add topics help
355
356
    Use an integer to specify a revision in the history of the branch.
4569.2.5 by Matthew Fuller
Update online documentation to match new DWIM behavior.
357
    Optionally a branch can be specified.  A negative number will count
358
    from the end of the branch (-1 is the last revision, -2 the previous
359
    one). If the negative number is larger than the branch's history, the
360
    first revision is returned.
2666.1.1 by Ian Clatworthy
Bazaar User Reference generated from online help
361
    Examples::
362
3651.2.1 by Daniel Clemente
Clarify that you don't have to write a path if you mean the current branch
363
      revno:1                   -> return the first revision of this branch
2023.1.1 by ghigo
add topics help
364
      revno:3:/path/to/branch   -> return the 3rd revision of
365
                                   the branch '/path/to/branch'
366
      revno:-1                  -> The last revision in a branch.
367
      -2:http://other/branch    -> The second to last revision in the
368
                                   remote branch.
369
      -1000000                  -> Most likely the first revision, unless
370
                                   your history is very long.
371
    """
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
372
    prefix = 'revno:'
373
374
    def _match_on(self, branch, revs):
375
        """Lookup a revision by revision number"""
6336.1.1 by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it.
376
        branch, revno, revision_id = self._lookup(branch)
3298.2.6 by John Arbash Meinel
Don't abstract through RevisionInfo for RevisionSpec_revno.as_revision_id()
377
        return RevisionInfo(branch, revno, revision_id)
378
6336.1.1 by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it.
379
    def _lookup(self, branch):
1948.4.1 by John Arbash Meinel
Update number parsers to raise InvalidRevisionSpec. Update revno: itself so it supports negative numbers
380
        loc = self.spec.find(':')
381
        if loc == -1:
382
            revno_spec = self.spec
383
            branch_spec = None
384
        else:
385
            revno_spec = self.spec[:loc]
7143.15.2 by Jelmer Vernooij
Run autopep8.
386
            branch_spec = self.spec[loc + 1:]
1948.4.1 by John Arbash Meinel
Update number parsers to raise InvalidRevisionSpec. Update revno: itself so it supports negative numbers
387
388
        if revno_spec == '':
1948.4.6 by John Arbash Meinel
A small bugfix, and more tests for revno:
389
            if not branch_spec:
7499.1.1 by Jelmer Vernooij
Move InvalidRevisionSpec to breezy.revisionspec.
390
                raise InvalidRevisionSpec(
391
                    self.user_spec, branch,
392
                    'cannot have an empty revno and no branch')
1948.4.1 by John Arbash Meinel
Update number parsers to raise InvalidRevisionSpec. Update revno: itself so it supports negative numbers
393
            revno = None
394
        else:
395
            try:
396
                revno = int(revno_spec)
1988.4.5 by Robert Collins
revisions can now be specified using dotted-decimal revision numbers.
397
                dotted = False
398
            except ValueError:
399
                # dotted decimal. This arguably should not be here
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
400
                # but the from_string method is a little primitive
1988.4.5 by Robert Collins
revisions can now be specified using dotted-decimal revision numbers.
401
                # right now - RBC 20060928
402
                try:
7143.15.2 by Jelmer Vernooij
Run autopep8.
403
                    match_revno = tuple((int(number)
404
                                         for number in revno_spec.split('.')))
6619.3.2 by Jelmer Vernooij
Apply 2to3 except fix.
405
                except ValueError as e:
7499.1.1 by Jelmer Vernooij
Move InvalidRevisionSpec to breezy.revisionspec.
406
                    raise InvalidRevisionSpec(self.user_spec, branch, e)
1988.4.5 by Robert Collins
revisions can now be specified using dotted-decimal revision numbers.
407
408
                dotted = True
1948.4.1 by John Arbash Meinel
Update number parsers to raise InvalidRevisionSpec. Update revno: itself so it supports negative numbers
409
1948.4.6 by John Arbash Meinel
A small bugfix, and more tests for revno:
410
        if branch_spec:
6336.1.1 by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it.
411
            # the user has overriden the branch to look in.
412
            branch = _mod_branch.Branch.open(branch_spec)
1948.4.22 by John Arbash Meinel
Refactor common code from integer revno handlers
413
1988.4.5 by Robert Collins
revisions can now be specified using dotted-decimal revision numbers.
414
        if dotted:
415
            try:
3949.2.6 by Ian Clatworthy
review feedback from jam
416
                revision_id = branch.dotted_revno_to_revision_id(match_revno,
7143.15.2 by Jelmer Vernooij
Run autopep8.
417
                                                                 _cache_reverse=True)
7290.19.7 by Jelmer Vernooij
Catch RevnoOutOfBounds.
418
            except (errors.NoSuchRevision, errors.RevnoOutOfBounds):
7499.1.1 by Jelmer Vernooij
Move InvalidRevisionSpec to breezy.revisionspec.
419
                raise InvalidRevisionSpec(self.user_spec, branch)
1948.4.27 by John Arbash Meinel
Deprecate calling RevisionSpec directly, and instead use a helper function. Also merge the old RevisionSpec_int class into RevisionSpec_revno
420
            else:
1988.4.5 by Robert Collins
revisions can now be specified using dotted-decimal revision numbers.
421
                # there is no traditional 'revno' for dotted-decimal revnos.
6336.1.1 by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it.
422
                # so for API compatibility we return None.
3949.2.6 by Ian Clatworthy
review feedback from jam
423
                return branch, None, revision_id
1988.4.5 by Robert Collins
revisions can now be specified using dotted-decimal revision numbers.
424
        else:
3060.3.3 by Lukáš Lalinský
Make RevisionSpec_revid and RevisionSpec_revno not load the whole revision history.
425
            last_revno, last_revision_id = branch.last_revision_info()
1988.4.5 by Robert Collins
revisions can now be specified using dotted-decimal revision numbers.
426
            if revno < 0:
2249.4.2 by Wouter van Heyst
Convert callers of Branch.revision_history() to Branch.last_revision_info() where sensible.
427
                # if get_rev_id supported negative revnos, there would not be a
428
                # need for this special case.
3060.3.3 by Lukáš Lalinský
Make RevisionSpec_revid and RevisionSpec_revno not load the whole revision history.
429
                if (-revno) >= last_revno:
1988.4.5 by Robert Collins
revisions can now be specified using dotted-decimal revision numbers.
430
                    revno = 1
431
                else:
3060.3.3 by Lukáš Lalinský
Make RevisionSpec_revid and RevisionSpec_revno not load the whole revision history.
432
                    revno = last_revno + revno + 1
1988.4.5 by Robert Collins
revisions can now be specified using dotted-decimal revision numbers.
433
            try:
6336.1.1 by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it.
434
                revision_id = branch.get_rev_id(revno)
7290.19.3 by Jelmer Vernooij
More tests.
435
            except (errors.NoSuchRevision, errors.RevnoOutOfBounds):
7499.1.1 by Jelmer Vernooij
Move InvalidRevisionSpec to breezy.revisionspec.
436
                raise InvalidRevisionSpec(self.user_spec, branch)
3298.2.6 by John Arbash Meinel
Don't abstract through RevisionInfo for RevisionSpec_revno.as_revision_id()
437
        return branch, revno, revision_id
3060.3.2 by Lukáš Lalinský
Make RevisionSpec_last not load the whole history.
438
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
439
    def _as_revision_id(self, context_branch):
440
        # We would have the revno here, but we don't really care
6336.1.1 by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it.
441
        branch, revno, revision_id = self._lookup(context_branch)
3298.2.6 by John Arbash Meinel
Don't abstract through RevisionInfo for RevisionSpec_revno.as_revision_id()
442
        return revision_id
3060.3.3 by Lukáš Lalinský
Make RevisionSpec_revid and RevisionSpec_revno not load the whole revision history.
443
1881.1.4 by Matthieu Moy
needs_tree -> needs_branch
444
    def needs_branch(self):
1881.1.1 by Matthieu Moy
Fixed and tested "bzr diff" outside a working tree.
445
        return self.spec.find(':') == -1
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
446
1907.4.1 by Matthieu Moy
Fixed merge to work nicely with -r revno:N:path
447
    def get_branch(self):
448
        if self.spec.find(':') == -1:
449
            return None
450
        else:
7143.15.2 by Jelmer Vernooij
Run autopep8.
451
            return self.spec[self.spec.find(':') + 1:]
452
1907.4.1 by Matthieu Moy
Fixed merge to work nicely with -r revno:N:path
453
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
454
# Old compatibility
1948.4.27 by John Arbash Meinel
Deprecate calling RevisionSpec directly, and instead use a helper function. Also merge the old RevisionSpec_int class into RevisionSpec_revno
455
RevisionSpec_int = RevisionSpec_revno
456
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
457
5365.6.4 by Aaron Bentley
Implement mainline revision spec.
458
class RevisionIDSpec(RevisionSpec):
459
460
    def _match_on(self, branch, revs):
461
        revision_id = self.as_revision_id(branch)
6336.1.1 by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it.
462
        return RevisionInfo.from_revision_id(branch, revision_id)
5365.6.4 by Aaron Bentley
Implement mainline revision spec.
463
464
465
class RevisionSpec_revid(RevisionIDSpec):
2070.4.14 by John Arbash Meinel
Switch revisionspec to use the help defined as help_txt rather than the doc string
466
    """Selects a revision using the revision id."""
467
468
    help_txt = """Selects a revision using the revision id.
2023.1.1 by ghigo
add topics help
469
470
    Supply a specific revision id, that can be used to specify any
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
471
    revision id in the ancestry of the branch.
2023.1.1 by ghigo
add topics help
472
    Including merges, and pending merges.
2666.1.1 by Ian Clatworthy
Bazaar User Reference generated from online help
473
    Examples::
474
2070.4.7 by ghigo
Updates on the basis of the Richard Wilbur suggestions
475
      revid:aaaa@bbbb-123456789 -> Select revision 'aaaa@bbbb-123456789'
3060.3.3 by Lukáš Lalinský
Make RevisionSpec_revid and RevisionSpec_revno not load the whole revision history.
476
    """
477
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
478
    prefix = 'revid:'
479
5365.6.4 by Aaron Bentley
Implement mainline revision spec.
480
    def _as_revision_id(self, context_branch):
2325.2.5 by Marien Zwart
Call osutils.safe_revision_id instead of duplicating it.
481
        # self.spec comes straight from parsing the command line arguments,
482
        # so we expect it to be a Unicode string. Switch it to the internal
483
        # representation.
7479.2.1 by Jelmer Vernooij
Drop python2 support.
484
        if isinstance(self.spec, str):
6630.1.1 by Jelmer Vernooij
Remove deprecated functionality.
485
            return cache_utf8.encode(self.spec)
486
        return self.spec
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
487
488
489
class RevisionSpec_last(RevisionSpec):
2070.4.14 by John Arbash Meinel
Switch revisionspec to use the help defined as help_txt rather than the doc string
490
    """Selects the nth revision from the end."""
491
492
    help_txt = """Selects the nth revision from the end.
2023.1.1 by ghigo
add topics help
493
494
    Supply a positive number to get the nth revision from the end.
2070.4.7 by ghigo
Updates on the basis of the Richard Wilbur suggestions
495
    This is the same as supplying negative numbers to the 'revno:' spec.
2666.1.1 by Ian Clatworthy
Bazaar User Reference generated from online help
496
    Examples::
497
2023.1.1 by ghigo
add topics help
498
      last:1        -> return the last revision
499
      last:3        -> return the revision 2 before the end.
3060.3.2 by Lukáš Lalinský
Make RevisionSpec_last not load the whole history.
500
    """
1185.1.39 by Robert Collins
Robey Pointers before: namespace to clear up usage of dates in revision parameters
501
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
502
    prefix = 'last:'
503
504
    def _match_on(self, branch, revs):
6336.1.1 by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it.
505
        revno, revision_id = self._revno_and_revision_id(branch)
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
506
        return RevisionInfo(branch, revno, revision_id)
507
6336.1.1 by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it.
508
    def _revno_and_revision_id(self, context_branch):
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
509
        last_revno, last_revision_id = context_branch.last_revision_info()
3060.3.2 by Lukáš Lalinský
Make RevisionSpec_last not load the whole history.
510
1948.4.9 by John Arbash Meinel
Cleanup and test last:
511
        if self.spec == '':
3060.3.2 by Lukáš Lalinský
Make RevisionSpec_last not load the whole history.
512
            if not last_revno:
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
513
                raise errors.NoCommits(context_branch)
514
            return last_revno, last_revision_id
1948.4.9 by John Arbash Meinel
Cleanup and test last:
515
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
516
        try:
517
            offset = int(self.spec)
6619.3.2 by Jelmer Vernooij
Apply 2to3 except fix.
518
        except ValueError as e:
7499.1.1 by Jelmer Vernooij
Move InvalidRevisionSpec to breezy.revisionspec.
519
            raise InvalidRevisionSpec(self.user_spec, context_branch, e)
1948.4.9 by John Arbash Meinel
Cleanup and test last:
520
521
        if offset <= 0:
7499.1.2 by Jelmer Vernooij
Fix formatting.
522
            raise InvalidRevisionSpec(
523
                self.user_spec, context_branch,
524
                'you must supply a positive value')
3060.3.2 by Lukáš Lalinský
Make RevisionSpec_last not load the whole history.
525
526
        revno = last_revno - offset + 1
1948.4.9 by John Arbash Meinel
Cleanup and test last:
527
        try:
6336.1.1 by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it.
528
            revision_id = context_branch.get_rev_id(revno)
7290.19.7 by Jelmer Vernooij
Catch RevnoOutOfBounds.
529
        except (errors.NoSuchRevision, errors.RevnoOutOfBounds):
7499.1.1 by Jelmer Vernooij
Move InvalidRevisionSpec to breezy.revisionspec.
530
            raise InvalidRevisionSpec(self.user_spec, context_branch)
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
531
        return revno, revision_id
532
533
    def _as_revision_id(self, context_branch):
534
        # We compute the revno as part of the process, but we don't really care
535
        # about it.
6336.1.1 by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it.
536
        revno, revision_id = self._revno_and_revision_id(context_branch)
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
537
        return revision_id
3060.3.2 by Lukáš Lalinský
Make RevisionSpec_last not load the whole history.
538
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
539
1185.1.39 by Robert Collins
Robey Pointers before: namespace to clear up usage of dates in revision parameters
540
class RevisionSpec_before(RevisionSpec):
2070.4.14 by John Arbash Meinel
Switch revisionspec to use the help defined as help_txt rather than the doc string
541
    """Selects the parent of the revision specified."""
542
543
    help_txt = """Selects the parent of the revision specified.
2023.1.1 by ghigo
add topics help
544
3651.2.4 by Daniel Clemente
Reordered to put explanation first and exceptions after
545
    Supply any revision spec to return the parent of that revision.  This is
546
    mostly useful when inspecting revisions that are not in the revision history
547
    of a branch.
548
2023.1.1 by ghigo
add topics help
549
    It is an error to request the parent of the null revision (before:0).
550
2666.1.1 by Ian Clatworthy
Bazaar User Reference generated from online help
551
    Examples::
552
2023.1.1 by ghigo
add topics help
553
      before:1913    -> Return the parent of revno 1913 (revno 1912)
554
      before:revid:aaaa@bbbb-1234567890  -> return the parent of revision
2070.4.7 by ghigo
Updates on the basis of the Richard Wilbur suggestions
555
                                            aaaa@bbbb-1234567890
3651.2.5 by Daniel Clemente
Wrote specifical and simpler example for 'before:', and referred to 'bzr diff -c'
556
      bzr diff -r before:1913..1913
557
            -> Find the changes between revision 1913 and its parent (1912).
558
               (What changes did revision 1913 introduce).
559
               This is equivalent to:  bzr diff -c 1913
2023.1.1 by ghigo
add topics help
560
    """
1185.1.39 by Robert Collins
Robey Pointers before: namespace to clear up usage of dates in revision parameters
561
562
    prefix = 'before:'
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
563
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
564
    def _match_on(self, branch, revs):
565
        r = RevisionSpec.from_string(self.spec)._match_on(branch, revs)
1948.4.13 by John Arbash Meinel
Going before:0 is an error, and if you are on another history, use the leftmost parent
566
        if r.revno == 0:
7499.1.1 by Jelmer Vernooij
Move InvalidRevisionSpec to breezy.revisionspec.
567
            raise InvalidRevisionSpec(
568
                self.user_spec, branch,
569
                'cannot go before the null: revision')
1948.4.13 by John Arbash Meinel
Going before:0 is an error, and if you are on another history, use the leftmost parent
570
        if r.revno is None:
571
            # We need to use the repository history here
572
            rev = branch.repository.get_revision(r.rev_id)
573
            if not rev.parent_ids:
2598.5.10 by Aaron Bentley
Return NULL_REVISION instead of None for the null revision
574
                revision_id = revision.NULL_REVISION
1948.4.13 by John Arbash Meinel
Going before:0 is an error, and if you are on another history, use the leftmost parent
575
            else:
576
                revision_id = rev.parent_ids[0]
6336.1.1 by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it.
577
            revno = None
1948.4.13 by John Arbash Meinel
Going before:0 is an error, and if you are on another history, use the leftmost parent
578
        else:
579
            revno = r.revno - 1
580
            try:
581
                revision_id = branch.get_rev_id(revno, revs)
7290.19.7 by Jelmer Vernooij
Catch RevnoOutOfBounds.
582
            except (errors.NoSuchRevision, errors.RevnoOutOfBounds):
7499.1.1 by Jelmer Vernooij
Move InvalidRevisionSpec to breezy.revisionspec.
583
                raise InvalidRevisionSpec(self.user_spec, branch)
1948.4.13 by John Arbash Meinel
Going before:0 is an error, and if you are on another history, use the leftmost parent
584
        return RevisionInfo(branch, revno, revision_id)
1185.1.39 by Robert Collins
Robey Pointers before: namespace to clear up usage of dates in revision parameters
585
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
586
    def _as_revision_id(self, context_branch):
7143.15.2 by Jelmer Vernooij
Run autopep8.
587
        base_revision_id = RevisionSpec.from_string(
588
            self.spec)._as_revision_id(context_branch)
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
589
        if base_revision_id == revision.NULL_REVISION:
7499.1.1 by Jelmer Vernooij
Move InvalidRevisionSpec to breezy.revisionspec.
590
            raise InvalidRevisionSpec(
591
                self.user_spec, context_branch,
592
                'cannot go before the null: revision')
3298.2.10 by Aaron Bentley
Refactor partial history code
593
        context_repo = context_branch.repository
7356.1.5 by Jelmer Vernooij
Use more ExitStacks.
594
        with context_repo.lock_read():
3298.2.10 by Aaron Bentley
Refactor partial history code
595
            parent_map = context_repo.get_parent_map([base_revision_id])
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
596
        if base_revision_id not in parent_map:
597
            # Ghost, or unknown revision id
7499.1.1 by Jelmer Vernooij
Move InvalidRevisionSpec to breezy.revisionspec.
598
            raise InvalidRevisionSpec(
599
                self.user_spec, context_branch, 'cannot find the matching revision')
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
600
        parents = parent_map[base_revision_id]
601
        if len(parents) < 1:
7499.1.1 by Jelmer Vernooij
Move InvalidRevisionSpec to breezy.revisionspec.
602
            raise errors.InvalidRevisionSpec(
603
                self.user_spec, context_branch, 'No parents for revision.')
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
604
        return parents[0]
3060.3.5 by Lukáš Lalinský
Add support for in_branch for the remaining RevisionSpec subclasses.
605
1185.1.39 by Robert Collins
Robey Pointers before: namespace to clear up usage of dates in revision parameters
606
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
607
class RevisionSpec_tag(RevisionSpec):
2220.2.3 by Martin Pool
Add tag: revision namespace.
608
    """Select a revision identified by tag name"""
609
610
    help_txt = """Selects a revision identified by a tag name.
611
1551.10.34 by Aaron Bentley
Fix tag: help
612
    Tags are stored in the branch and created by the 'tag' command.
2220.2.3 by Martin Pool
Add tag: revision namespace.
613
    """
2070.4.14 by John Arbash Meinel
Switch revisionspec to use the help defined as help_txt rather than the doc string
614
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
615
    prefix = 'tag:'
4569.2.18 by Vincent Ladeuil
Small refactoring to unblock the submission.
616
    dwim_catchable_exceptions = (errors.NoSuchTag, errors.TagsNotSupported)
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
617
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
618
    def _match_on(self, branch, revs):
2220.2.3 by Martin Pool
Add tag: revision namespace.
619
        # Can raise tags not supported, NoSuchTag, etc
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
620
        return RevisionInfo.from_revision_id(branch,
7143.15.2 by Jelmer Vernooij
Run autopep8.
621
                                             branch.tags.lookup_tag(self.spec))
3060.3.5 by Lukáš Lalinský
Add support for in_branch for the remaining RevisionSpec subclasses.
622
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
623
    def _as_revision_id(self, context_branch):
624
        return context_branch.tags.lookup_tag(self.spec)
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
625
626
1948.4.12 by John Arbash Meinel
Some tests for the date: spec
627
class _RevListToTimestamps(object):
628
    """This takes a list of revisions, and allows you to bisect by date"""
629
6336.1.1 by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it.
630
    __slots__ = ['branch']
1948.4.12 by John Arbash Meinel
Some tests for the date: spec
631
6336.1.1 by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it.
632
    def __init__(self, branch):
1688.2.2 by Guillaume Pinot
Binary search for 'date:' revision.
633
        self.branch = branch
1948.4.12 by John Arbash Meinel
Some tests for the date: spec
634
1688.2.2 by Guillaume Pinot
Binary search for 'date:' revision.
635
    def __getitem__(self, index):
1948.4.12 by John Arbash Meinel
Some tests for the date: spec
636
        """Get the date of the index'd item"""
6336.1.1 by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it.
637
        r = self.branch.repository.get_revision(self.branch.get_rev_id(index))
1688.2.2 by Guillaume Pinot
Binary search for 'date:' revision.
638
        # TODO: Handle timezone.
639
        return datetime.datetime.fromtimestamp(r.timestamp)
1948.4.12 by John Arbash Meinel
Some tests for the date: spec
640
1688.2.2 by Guillaume Pinot
Binary search for 'date:' revision.
641
    def __len__(self):
6336.1.1 by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it.
642
        return self.branch.revno()
1688.2.2 by Guillaume Pinot
Binary search for 'date:' revision.
643
644
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
645
class RevisionSpec_date(RevisionSpec):
2070.4.14 by John Arbash Meinel
Switch revisionspec to use the help defined as help_txt rather than the doc string
646
    """Selects a revision on the basis of a datestamp."""
647
648
    help_txt = """Selects a revision on the basis of a datestamp.
2023.1.1 by ghigo
add topics help
649
650
    Supply a datestamp to select the first revision that matches the date.
651
    Date can be 'yesterday', 'today', 'tomorrow' or a YYYY-MM-DD string.
652
    Matches the first entry after a given date (either at midnight or
653
    at a specified time).
654
2666.1.1 by Ian Clatworthy
Bazaar User Reference generated from online help
655
    One way to display all the changes since yesterday would be::
2666.1.5 by Ian Clatworthy
Incorporate feedback from Alex B. & James W.
656
6622.1.30 by Jelmer Vernooij
Some more test fixes.
657
        brz log -r date:yesterday..
2023.1.1 by ghigo
add topics help
658
2666.1.1 by Ian Clatworthy
Bazaar User Reference generated from online help
659
    Examples::
660
2023.1.1 by ghigo
add topics help
661
      date:yesterday            -> select the first revision since yesterday
662
      date:2006-08-14,17:10:14  -> select the first revision after
663
                                   August 14th, 2006 at 5:10pm.
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
664
    """
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
665
    prefix = 'date:'
5685.1.1 by Jelmer Vernooij
More lazy imports, lazy regexes in bzrlib.revisionspec.
666
    _date_regex = lazy_regex.lazy_compile(
7143.15.2 by Jelmer Vernooij
Run autopep8.
667
        r'(?P<date>(?P<year>\d\d\d\d)-(?P<month>\d\d)-(?P<day>\d\d))?'
668
        r'(,|T)?\s*'
669
        r'(?P<time>(?P<hour>\d\d):(?P<minute>\d\d)(:(?P<second>\d\d))?)?'
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
670
        )
671
672
    def _match_on(self, branch, revs):
2023.1.1 by ghigo
add topics help
673
        """Spec for date revisions:
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
674
          date:value
675
          value can be 'yesterday', 'today', 'tomorrow' or a YYYY-MM-DD string.
1185.1.39 by Robert Collins
Robey Pointers before: namespace to clear up usage of dates in revision parameters
676
          matches the first entry after a given date (either at midnight or
677
          at a specified time).
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
678
        """
2070.4.3 by John Arbash Meinel
code and doc cleanup
679
        #  XXX: This doesn't actually work
680
        #  So the proper way of saying 'give me all entries for today' is:
681
        #      -r date:yesterday..date:today
7143.15.2 by Jelmer Vernooij
Run autopep8.
682
        today = datetime.datetime.fromordinal(
683
            datetime.date.today().toordinal())
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
684
        if self.spec.lower() == 'yesterday':
685
            dt = today - datetime.timedelta(days=1)
686
        elif self.spec.lower() == 'today':
687
            dt = today
688
        elif self.spec.lower() == 'tomorrow':
689
            dt = today + datetime.timedelta(days=1)
690
        else:
5685.1.1 by Jelmer Vernooij
More lazy imports, lazy regexes in bzrlib.revisionspec.
691
            m = self._date_regex.match(self.spec)
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
692
            if not m or (not m.group('date') and not m.group('time')):
7499.1.1 by Jelmer Vernooij
Move InvalidRevisionSpec to breezy.revisionspec.
693
                raise InvalidRevisionSpec(
694
                    self.user_spec, branch, 'invalid date')
1948.4.12 by John Arbash Meinel
Some tests for the date: spec
695
696
            try:
697
                if m.group('date'):
698
                    year = int(m.group('year'))
699
                    month = int(m.group('month'))
700
                    day = int(m.group('day'))
701
                else:
702
                    year = today.year
703
                    month = today.month
704
                    day = today.day
705
706
                if m.group('time'):
707
                    hour = int(m.group('hour'))
708
                    minute = int(m.group('minute'))
709
                    if m.group('second'):
710
                        second = int(m.group('second'))
711
                    else:
712
                        second = 0
713
                else:
6809.1.1 by Martin
Apply 2to3 ws_comma fixer
714
                    hour, minute, second = 0, 0, 0
1948.4.12 by John Arbash Meinel
Some tests for the date: spec
715
            except ValueError:
7499.1.1 by Jelmer Vernooij
Move InvalidRevisionSpec to breezy.revisionspec.
716
                raise InvalidRevisionSpec(
717
                    self.user_spec, branch, 'invalid date')
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
718
719
            dt = datetime.datetime(year=year, month=month, day=day,
7143.15.2 by Jelmer Vernooij
Run autopep8.
720
                                   hour=hour, minute=minute, second=second)
6754.8.4 by Jelmer Vernooij
Use new context stuff.
721
        with branch.lock_read():
6336.1.1 by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it.
722
            rev = bisect.bisect(_RevListToTimestamps(branch), dt, 1)
723
        if rev == branch.revno():
7499.1.1 by Jelmer Vernooij
Move InvalidRevisionSpec to breezy.revisionspec.
724
            raise InvalidRevisionSpec(self.user_spec, branch)
6336.1.1 by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it.
725
        return RevisionInfo(branch, rev)
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
726
727
728
class RevisionSpec_ancestor(RevisionSpec):
2070.4.14 by John Arbash Meinel
Switch revisionspec to use the help defined as help_txt rather than the doc string
729
    """Selects a common ancestor with a second branch."""
730
731
    help_txt = """Selects a common ancestor with a second branch.
2023.1.1 by ghigo
add topics help
732
733
    Supply the path to a branch to select the common ancestor.
734
735
    The common ancestor is the last revision that existed in both
736
    branches. Usually this is the branch point, but it could also be
737
    a revision that was merged.
738
739
    This is frequently used with 'diff' to return all of the changes
740
    that your branch introduces, while excluding the changes that you
741
    have not merged from the remote branch.
742
2666.1.1 by Ian Clatworthy
Bazaar User Reference generated from online help
743
    Examples::
744
2023.1.1 by ghigo
add topics help
745
      ancestor:/path/to/branch
2070.4.7 by ghigo
Updates on the basis of the Richard Wilbur suggestions
746
      $ bzr diff -r ancestor:../../mainline/branch
2023.1.1 by ghigo
add topics help
747
    """
1185.11.5 by John Arbash Meinel
Merged up-to-date against mainline, still broken.
748
    prefix = 'ancestor:'
749
750
    def _match_on(self, branch, revs):
1551.10.33 by Aaron Bentley
Updates from review
751
        trace.mutter('matching ancestor: on: %s, %s', self.spec, branch)
752
        return self._find_revision_info(branch, self.spec)
753
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
754
    def _as_revision_id(self, context_branch):
755
        return self._find_revision_id(context_branch, self.spec)
756
1551.10.33 by Aaron Bentley
Updates from review
757
    @staticmethod
758
    def _find_revision_info(branch, other_location):
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
759
        revision_id = RevisionSpec_ancestor._find_revision_id(branch,
760
                                                              other_location)
6336.1.1 by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it.
761
        return RevisionInfo(branch, None, revision_id)
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
762
763
    @staticmethod
764
    def _find_revision_id(branch, other_location):
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
765
        from .branch import Branch
1948.4.18 by John Arbash Meinel
Update branch: spec and tests
766
6754.8.4 by Jelmer Vernooij
Use new context stuff.
767
        with branch.lock_read():
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
768
            revision_a = revision.ensure_null(branch.last_revision())
769
            if revision_a == revision.NULL_REVISION:
770
                raise errors.NoCommits(branch)
3984.1.2 by Daniel Watkins
Added fix.
771
            if other_location == '':
772
                other_location = branch.get_parent()
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
773
            other_branch = Branch.open(other_location)
6754.8.4 by Jelmer Vernooij
Use new context stuff.
774
            with other_branch.lock_read():
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
775
                revision_b = revision.ensure_null(other_branch.last_revision())
776
                if revision_b == revision.NULL_REVISION:
777
                    raise errors.NoCommits(other_branch)
778
                graph = branch.repository.get_graph(other_branch.repository)
3010.1.12 by Robert Collins
Lock branches while doing revision specification lookups.
779
                rev_id = graph.find_unique_lca(revision_a, revision_b)
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
780
            if rev_id == revision.NULL_REVISION:
781
                raise errors.NoCommonAncestor(revision_a, revision_b)
782
            return rev_id
1432 by Robert Collins
branch: namespace
783
1948.4.16 by John Arbash Meinel
Move the tests into the associated tester, remove redundant tests, some small PEP8 changes
784
1432 by Robert Collins
branch: namespace
785
class RevisionSpec_branch(RevisionSpec):
2070.4.14 by John Arbash Meinel
Switch revisionspec to use the help defined as help_txt rather than the doc string
786
    """Selects the last revision of a specified branch."""
787
788
    help_txt = """Selects the last revision of a specified branch.
2023.1.1 by ghigo
add topics help
789
790
    Supply the path to a branch to select its last revision.
791
2666.1.1 by Ian Clatworthy
Bazaar User Reference generated from online help
792
    Examples::
793
2023.1.1 by ghigo
add topics help
794
      branch:/path/to/branch
1432 by Robert Collins
branch: namespace
795
    """
796
    prefix = 'branch:'
4569.2.18 by Vincent Ladeuil
Small refactoring to unblock the submission.
797
    dwim_catchable_exceptions = (errors.NotBranchError,)
1432 by Robert Collins
branch: namespace
798
799
    def _match_on(self, branch, revs):
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
800
        from .branch import Branch
1948.4.18 by John Arbash Meinel
Update branch: spec and tests
801
        other_branch = Branch.open(self.spec)
1432 by Robert Collins
branch: namespace
802
        revision_b = other_branch.last_revision()
1948.4.18 by John Arbash Meinel
Update branch: spec and tests
803
        if revision_b in (None, revision.NULL_REVISION):
1948.4.26 by John Arbash Meinel
Get rid of direct imports of exceptions
804
            raise errors.NoCommits(other_branch)
5318.1.1 by Martin von Gagern
Extract branch location from branch: revision specs.
805
        if branch is None:
806
            branch = other_branch
807
        else:
808
            try:
809
                # pull in the remote revisions so we can diff
810
                branch.fetch(other_branch, revision_b)
811
            except errors.ReadOnlyError:
812
                branch = other_branch
6336.1.1 by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it.
813
        return RevisionInfo(branch, None, revision_b)
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
814
815
    def _as_revision_id(self, context_branch):
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
816
        from .branch import Branch
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
817
        other_branch = Branch.open(self.spec)
818
        last_revision = other_branch.last_revision()
819
        last_revision = revision.ensure_null(last_revision)
1551.19.33 by Aaron Bentley
Use as_revision_id for diff
820
        context_branch.fetch(other_branch, last_revision)
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
821
        if last_revision == revision.NULL_REVISION:
822
            raise errors.NoCommits(other_branch)
823
        return last_revision
824
3655.3.1 by Lukáš Lalinský
Fix `bzr st -rbranch:PATH_TO_BRANCH`
825
    def _as_tree(self, context_branch):
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
826
        from .branch import Branch
3655.3.1 by Lukáš Lalinský
Fix `bzr st -rbranch:PATH_TO_BRANCH`
827
        other_branch = Branch.open(self.spec)
828
        last_revision = other_branch.last_revision()
829
        last_revision = revision.ensure_null(last_revision)
830
        if last_revision == revision.NULL_REVISION:
831
            raise errors.NoCommits(other_branch)
832
        return other_branch.repository.revision_tree(last_revision)
833
5318.1.1 by Martin von Gagern
Extract branch location from branch: revision specs.
834
    def needs_branch(self):
835
        return False
836
837
    def get_branch(self):
838
        return self.spec
839
1551.10.32 by Aaron Bentley
Add submit: specifier, for merge-directive-like diffs
840
1551.10.33 by Aaron Bentley
Updates from review
841
class RevisionSpec_submit(RevisionSpec_ancestor):
1551.10.32 by Aaron Bentley
Add submit: specifier, for merge-directive-like diffs
842
    """Selects a common ancestor with a submit branch."""
843
844
    help_txt = """Selects a common ancestor with the submit branch.
845
846
    Diffing against this shows all the changes that were made in this branch,
847
    and is a good predictor of what merge will do.  The submit branch is
3565.2.1 by Christophe Troestler
(trivial) Corrected typos.
848
    used by the bundle and merge directive commands.  If no submit branch
1551.10.32 by Aaron Bentley
Add submit: specifier, for merge-directive-like diffs
849
    is specified, the parent branch is used instead.
850
851
    The common ancestor is the last revision that existed in both
852
    branches. Usually this is the branch point, but it could also be
853
    a revision that was merged.
854
2666.1.1 by Ian Clatworthy
Bazaar User Reference generated from online help
855
    Examples::
856
1551.10.32 by Aaron Bentley
Add submit: specifier, for merge-directive-like diffs
857
      $ bzr diff -r submit:
858
    """
1551.10.33 by Aaron Bentley
Updates from review
859
1551.10.32 by Aaron Bentley
Add submit: specifier, for merge-directive-like diffs
860
    prefix = 'submit:'
861
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
862
    def _get_submit_location(self, branch):
1551.10.32 by Aaron Bentley
Add submit: specifier, for merge-directive-like diffs
863
        submit_location = branch.get_submit_branch()
1551.10.35 by Aaron Bentley
Add note about which branch is selected by submit:
864
        location_type = 'submit branch'
1551.10.32 by Aaron Bentley
Add submit: specifier, for merge-directive-like diffs
865
        if submit_location is None:
866
            submit_location = branch.get_parent()
1551.10.35 by Aaron Bentley
Add note about which branch is selected by submit:
867
            location_type = 'parent branch'
1551.10.32 by Aaron Bentley
Add submit: specifier, for merge-directive-like diffs
868
        if submit_location is None:
869
            raise errors.NoSubmitBranch(branch)
6147.1.1 by Jonathan Riddell
use .format() instead of % for string formatting where there are multiple formats in one string to allow for translations
870
        trace.note(gettext('Using {0} {1}').format(location_type,
7143.15.2 by Jelmer Vernooij
Run autopep8.
871
                                                   submit_location))
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
872
        return submit_location
873
874
    def _match_on(self, branch, revs):
875
        trace.mutter('matching ancestor: on: %s, %s', self.spec, branch)
876
        return self._find_revision_info(branch,
7143.15.2 by Jelmer Vernooij
Run autopep8.
877
                                        self._get_submit_location(branch))
3298.2.5 by John Arbash Meinel
Start implementing everything in terms of cheaper _as_revision_id lookups.
878
879
    def _as_revision_id(self, context_branch):
880
        return self._find_revision_id(context_branch,
7143.15.2 by Jelmer Vernooij
Run autopep8.
881
                                      self._get_submit_location(context_branch))
1551.10.33 by Aaron Bentley
Updates from review
882
1551.10.35 by Aaron Bentley
Add note about which branch is selected by submit:
883
5365.6.6 by Aaron Bentley
Implement 'annotate' revision-id.
884
class RevisionSpec_annotate(RevisionIDSpec):
885
886
    prefix = 'annotate:'
887
888
    help_txt = """Select the revision that last modified the specified line.
889
890
    Select the revision that last modified the specified line.  Line is
891
    specified as path:number.  Path is a relative path to the file.  Numbers
892
    start at 1, and are relative to the current version, not the last-
893
    committed version of the file.
894
    """
895
896
    def _raise_invalid(self, numstring, context_branch):
7499.1.1 by Jelmer Vernooij
Move InvalidRevisionSpec to breezy.revisionspec.
897
        raise InvalidRevisionSpec(
898
            self.user_spec, context_branch,
899
            'No such line: %s' % numstring)
5365.6.6 by Aaron Bentley
Implement 'annotate' revision-id.
900
901
    def _as_revision_id(self, context_branch):
902
        path, numstring = self.spec.rsplit(':', 1)
903
        try:
904
            index = int(numstring) - 1
905
        except ValueError:
906
            self._raise_invalid(numstring, context_branch)
907
        tree, file_path = workingtree.WorkingTree.open_containing(path)
6754.8.4 by Jelmer Vernooij
Use new context stuff.
908
        with tree.lock_read():
6809.4.2 by Jelmer Vernooij
Swap arguments for annotate_iter.
909
            if not tree.has_filename(file_path):
7499.1.1 by Jelmer Vernooij
Move InvalidRevisionSpec to breezy.revisionspec.
910
                raise InvalidRevisionSpec(
911
                    self.user_spec, context_branch,
912
                    "File '%s' is not versioned." % file_path)
6809.4.2 by Jelmer Vernooij
Swap arguments for annotate_iter.
913
            revision_ids = [r for (r, l) in tree.annotate_iter(file_path)]
5365.6.6 by Aaron Bentley
Implement 'annotate' revision-id.
914
        try:
915
            revision_id = revision_ids[index]
916
        except IndexError:
917
            self._raise_invalid(numstring, context_branch)
918
        if revision_id == revision.CURRENT_REVISION:
7499.1.1 by Jelmer Vernooij
Move InvalidRevisionSpec to breezy.revisionspec.
919
            raise InvalidRevisionSpec(
920
                self.user_spec, context_branch,
921
                'Line %s has not been committed.' % numstring)
5365.6.6 by Aaron Bentley
Implement 'annotate' revision-id.
922
        return revision_id
923
924
5365.6.4 by Aaron Bentley
Implement mainline revision spec.
925
class RevisionSpec_mainline(RevisionIDSpec):
926
927
    help_txt = """Select mainline revision that merged the specified revision.
928
929
    Select the revision that merged the specified revision into mainline.
930
    """
931
932
    prefix = 'mainline:'
933
934
    def _as_revision_id(self, context_branch):
935
        revspec = RevisionSpec.from_string(self.spec)
936
        if revspec.get_branch() is None:
937
            spec_branch = context_branch
938
        else:
939
            spec_branch = _mod_branch.Branch.open(revspec.get_branch())
940
        revision_id = revspec.as_revision_id(spec_branch)
941
        graph = context_branch.repository.get_graph()
942
        result = graph.find_lefthand_merger(revision_id,
943
                                            context_branch.last_revision())
944
        if result is None:
7499.1.1 by Jelmer Vernooij
Move InvalidRevisionSpec to breezy.revisionspec.
945
            raise InvalidRevisionSpec(self.user_spec, context_branch)
5365.6.4 by Aaron Bentley
Implement mainline revision spec.
946
        return result
947
948
4569.2.18 by Vincent Ladeuil
Small refactoring to unblock the submission.
949
# The order in which we want to DWIM a revision spec without any prefix.
950
# revno is always tried first and isn't listed here, this is used by
951
# RevisionSpec_dwim._match_on
5671.5.1 by Jelmer Vernooij
Allow lazily registering possible DWIM revspecs.
952
RevisionSpec_dwim.append_possible_revspec(RevisionSpec_tag)
953
RevisionSpec_dwim.append_possible_revspec(RevisionSpec_revid)
954
RevisionSpec_dwim.append_possible_revspec(RevisionSpec_date)
955
RevisionSpec_dwim.append_possible_revspec(RevisionSpec_branch)
4569.2.18 by Vincent Ladeuil
Small refactoring to unblock the submission.
956
3966.2.1 by Jelmer Vernooij
Register revision specifiers in a registry.
957
revspec_registry = registry.Registry()
7143.15.2 by Jelmer Vernooij
Run autopep8.
958
959
3966.2.1 by Jelmer Vernooij
Register revision specifiers in a registry.
960
def _register_revspec(revspec):
961
    revspec_registry.register(revspec.prefix, revspec)
962
7143.15.2 by Jelmer Vernooij
Run autopep8.
963
3966.2.1 by Jelmer Vernooij
Register revision specifiers in a registry.
964
_register_revspec(RevisionSpec_revno)
965
_register_revspec(RevisionSpec_revid)
966
_register_revspec(RevisionSpec_last)
967
_register_revspec(RevisionSpec_before)
968
_register_revspec(RevisionSpec_tag)
969
_register_revspec(RevisionSpec_date)
970
_register_revspec(RevisionSpec_ancestor)
971
_register_revspec(RevisionSpec_branch)
972
_register_revspec(RevisionSpec_submit)
5365.6.6 by Aaron Bentley
Implement 'annotate' revision-id.
973
_register_revspec(RevisionSpec_annotate)
5365.6.4 by Aaron Bentley
Implement mainline revision spec.
974
_register_revspec(RevisionSpec_mainline)