~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revisionspec.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-01-27 20:24:43 UTC
  • mfrom: (3960.2.1 1.12-progress-warnings)
  • Revision ID: pqm@pqm.ubuntu.com-20090127202443-ty2bu1hh91dumasz
(jam) Avoid getting a UserWarning by not creating an unused progress
        bar.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
from bzrlib import (
27
27
    errors,
28
28
    osutils,
29
 
    registry,
30
29
    revision,
31
30
    symbol_versioning,
32
31
    trace,
115
114
 
116
115
# classes in this list should have a "prefix" attribute, against which
117
116
# string specs are matched
 
117
SPEC_TYPES = []
118
118
_revno_regex = None
119
119
 
120
120
 
153
153
 
154
154
        if spec is None:
155
155
            return RevisionSpec(None, _internal=True)
156
 
        match = revspec_registry.get_prefix(spec)
157
 
        if match is not None:
158
 
            spectype, specsuffix = match
159
 
            trace.mutter('Returning RevisionSpec %s for %s',
160
 
                         spectype.__name__, spec)
161
 
            return spectype(spec, _internal=True)
162
 
        else:
163
 
            for spectype in SPEC_TYPES:
 
156
        for spectype in SPEC_TYPES:
 
157
            if spec.startswith(spectype.prefix):
164
158
                trace.mutter('Returning RevisionSpec %s for %s',
165
159
                             spectype.__name__, spec)
166
 
                if spec.startswith(spectype.prefix):
167
 
                    return spectype(spec, _internal=True)
 
160
                return spectype(spec, _internal=True)
 
161
        else:
168
162
            # RevisionSpec_revno is special cased, because it is the only
169
163
            # one that directly handles plain integers
170
164
            # TODO: This should not be special cased rather it should be
399
393
# Old compatibility 
400
394
RevisionSpec_int = RevisionSpec_revno
401
395
 
 
396
SPEC_TYPES.append(RevisionSpec_revno)
402
397
 
403
398
 
404
399
class RevisionSpec_revid(RevisionSpec):
426
421
    def _as_revision_id(self, context_branch):
427
422
        return osutils.safe_revision_id(self.spec, warn=False)
428
423
 
 
424
SPEC_TYPES.append(RevisionSpec_revid)
429
425
 
430
426
 
431
427
class RevisionSpec_last(RevisionSpec):
477
473
        revno, revision_id = self._revno_and_revision_id(context_branch, None)
478
474
        return revision_id
479
475
 
 
476
SPEC_TYPES.append(RevisionSpec_last)
480
477
 
481
478
 
482
479
class RevisionSpec_before(RevisionSpec):
551
548
                'No parents for revision.')
552
549
        return parents[0]
553
550
 
 
551
SPEC_TYPES.append(RevisionSpec_before)
554
552
 
555
553
 
556
554
class RevisionSpec_tag(RevisionSpec):
572
570
    def _as_revision_id(self, context_branch):
573
571
        return context_branch.tags.lookup_tag(self.spec)
574
572
 
 
573
SPEC_TYPES.append(RevisionSpec_tag)
575
574
 
576
575
 
577
576
class _RevListToTimestamps(object):
678
677
        else:
679
678
            return RevisionInfo(branch, rev + 1)
680
679
 
 
680
SPEC_TYPES.append(RevisionSpec_date)
681
681
 
682
682
 
683
683
class RevisionSpec_ancestor(RevisionSpec):
745
745
            branch.unlock()
746
746
 
747
747
 
 
748
SPEC_TYPES.append(RevisionSpec_ancestor)
748
749
 
749
750
 
750
751
class RevisionSpec_branch(RevisionSpec):
793
794
            raise errors.NoCommits(other_branch)
794
795
        return other_branch.repository.revision_tree(last_revision)
795
796
 
 
797
SPEC_TYPES.append(RevisionSpec_branch)
796
798
 
797
799
 
798
800
class RevisionSpec_submit(RevisionSpec_ancestor):
837
839
            self._get_submit_location(context_branch))
838
840
 
839
841
 
840
 
revspec_registry = registry.Registry()
841
 
def _register_revspec(revspec):
842
 
    revspec_registry.register(revspec.prefix, revspec)
843
 
 
844
 
_register_revspec(RevisionSpec_revno)
845
 
_register_revspec(RevisionSpec_revid)
846
 
_register_revspec(RevisionSpec_last)
847
 
_register_revspec(RevisionSpec_before)
848
 
_register_revspec(RevisionSpec_tag)
849
 
_register_revspec(RevisionSpec_date)
850
 
_register_revspec(RevisionSpec_ancestor)
851
 
_register_revspec(RevisionSpec_branch)
852
 
_register_revspec(RevisionSpec_submit)
853
 
 
854
 
SPEC_TYPES = symbol_versioning.deprecated_list(
855
 
    symbol_versioning.deprecated_in((1, 12, 0)), "SPEC_TYPES", [])
 
842
SPEC_TYPES.append(RevisionSpec_submit)