/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/revisionspec.py

  • Committer: Jelmer Vernooij
  • Date: 2011-02-20 00:18:58 UTC
  • mto: This revision was merged to the branch mainline in revision 5687.
  • Revision ID: jelmer@samba.org-20110220001858-0mlsuko46nhbron9
Allow lazily registering possible DWIM revspecs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
304
304
    # each revspec we try.
305
305
    wants_revision_history = False
306
306
 
 
307
    # The revspecs to try
 
308
    _possible_revspecs = []
 
309
 
307
310
    def _try_spectype(self, rstype, branch):
308
311
        rs = rstype(self.spec, _internal=True)
309
312
        # Hit in_history to find out if it exists, or we need to try the
324
327
                pass
325
328
 
326
329
        # Next see what has been registered
 
330
        for objgetter in self._possible_revspecs:
 
331
            rs_class = objgetter.get_obj()
 
332
            try:
 
333
                return self._try_spectype(rs_class, branch)
 
334
            except rs_class.dwim_catchable_exceptions:
 
335
                pass
 
336
 
 
337
        # Try the old (deprecated) dwim list:
327
338
        for rs_class in dwim_revspecs:
328
339
            try:
329
340
                return self._try_spectype(rs_class, branch)
335
346
        # really relevant.
336
347
        raise errors.InvalidRevisionSpec(self.spec, branch)
337
348
 
 
349
    def append_possible_revspec(self, revspec):
 
350
        """Append a possible DWIM revspec.
 
351
 
 
352
        :param revspec: Revision spec to try.
 
353
        """
 
354
        self._possible_revspecs.append(registry._ObjectGetter(revspec))
 
355
 
 
356
    def append_possible_lazy_revspec(self, module_name, member_name):
 
357
        """Append a possible lazily loaded DWIM revspec.
 
358
 
 
359
        :param module_name: Name of the module with the revspec
 
360
        :param member_name: Name of the revspec within the module
 
361
        """
 
362
        self._possible_revspecs.append(
 
363
            registry._LazyObjectGetter(module_name, member_name))
 
364
 
338
365
 
339
366
class RevisionSpec_revno(RevisionSpec):
340
367
    """Selects a revision using a number."""
971
998
# The order in which we want to DWIM a revision spec without any prefix.
972
999
# revno is always tried first and isn't listed here, this is used by
973
1000
# RevisionSpec_dwim._match_on
974
 
dwim_revspecs = [
975
 
    RevisionSpec_tag, # Let's try for a tag
976
 
    RevisionSpec_revid, # Maybe it's a revid?
977
 
    RevisionSpec_date, # Perhaps a date?
978
 
    RevisionSpec_branch, # OK, last try, maybe it's a branch
979
 
    ]
 
1001
dwim_revspecs = symbol_versioning.deprecated_list(
 
1002
    symbol_versioning.deprecated_in((2, 4, 0)), "dwim_revspecs", [])
980
1003
 
 
1004
RevisionSpec_dwim.append_possible_revspec(RevisionSpec_tag)
 
1005
RevisionSpec_dwim.append_possible_revspec(RevisionSpec_revid)
 
1006
RevisionSpec_dwim.append_possible_revspec(RevisionSpec_date)
 
1007
RevisionSpec_dwim.append_possible_revspec(RevisionSpec_branch)
981
1008
 
982
1009
revspec_registry = registry.Registry()
983
1010
def _register_revspec(revspec):