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