~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revisionspec.py

  • Committer: Jelmer Vernooij
  • Date: 2011-03-08 17:51:43 UTC
  • mfrom: (5684.2.5 per-repository-vf)
  • mto: This revision was merged to the branch mainline in revision 5710.
  • Revision ID: jelmer@samba.org-20110308175143-949n8c8lodfb4tvc
Merge per-repository-vf, move scenarios to test_check_reconcile.

Show diffs side-by-side

added added

removed removed

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