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