~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revisionspec.py

(gz) Fix test failure on alpha by correcting format string for
 gc_chk_sha1_record (Martin [gz])

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
 
18
import re
 
19
 
18
20
from bzrlib.lazy_import import lazy_import
19
21
lazy_import(globals(), """
20
22
import bisect
21
23
import datetime
22
24
 
23
25
from bzrlib import (
 
26
    workingtree,
 
27
    )
 
28
""")
 
29
 
 
30
from bzrlib import (
24
31
    branch as _mod_branch,
 
32
    errors,
25
33
    osutils,
 
34
    registry,
26
35
    revision,
27
36
    symbol_versioning,
28
 
    workingtree,
29
 
    )
30
 
from bzrlib.i18n import gettext
31
 
""")
32
 
 
33
 
from bzrlib import (
34
 
    errors,
35
 
    lazy_regex,
36
 
    registry,
37
37
    trace,
 
38
    workingtree,
38
39
    )
39
40
 
40
41
 
118
119
        return RevisionInfo(branch, revno, revision_id)
119
120
 
120
121
 
 
122
_revno_regex = None
 
123
 
 
124
 
121
125
class RevisionSpec(object):
122
126
    """A parsed revision specification."""
123
127
 
299
303
    # each revspec we try.
300
304
    wants_revision_history = False
301
305
 
302
 
    _revno_regex = lazy_regex.lazy_compile(r'^(?:(\d+(\.\d+)*)|-\d+)(:.*)?$')
303
 
 
304
306
    # The revspecs to try
305
307
    _possible_revspecs = []
306
308
 
314
316
        """Run the lookup and see what we can get."""
315
317
 
316
318
        # First, see if it's a revno
317
 
        if self._revno_regex.match(self.spec) is not None:
 
319
        global _revno_regex
 
320
        if _revno_regex is None:
 
321
            _revno_regex = re.compile(r'^(?:(\d+(\.\d+)*)|-\d+)(:.*)?$')
 
322
        if _revno_regex.match(self.spec) is not None:
318
323
            try:
319
324
                return self._try_spectype(RevisionSpec_revno, branch)
320
325
            except RevisionSpec_revno.dwim_catchable_exceptions:
686
691
                                   August 14th, 2006 at 5:10pm.
687
692
    """
688
693
    prefix = 'date:'
689
 
    _date_regex = lazy_regex.lazy_compile(
 
694
    _date_re = re.compile(
690
695
            r'(?P<date>(?P<year>\d\d\d\d)-(?P<month>\d\d)-(?P<day>\d\d))?'
691
696
            r'(,|T)?\s*'
692
697
            r'(?P<time>(?P<hour>\d\d):(?P<minute>\d\d)(:(?P<second>\d\d))?)?'
710
715
        elif self.spec.lower() == 'tomorrow':
711
716
            dt = today + datetime.timedelta(days=1)
712
717
        else:
713
 
            m = self._date_regex.match(self.spec)
 
718
            m = self._date_re.match(self.spec)
714
719
            if not m or (not m.group('date') and not m.group('time')):
715
720
                raise errors.InvalidRevisionSpec(self.user_spec,
716
721
                                                 branch, 'invalid date')
911
916
            location_type = 'parent branch'
912
917
        if submit_location is None:
913
918
            raise errors.NoSubmitBranch(branch)
914
 
        trace.note(gettext('Using {0} {1}').format(location_type,
915
 
                                                        submit_location))
 
919
        trace.note('Using %s %s', location_type, submit_location)
916
920
        return submit_location
917
921
 
918
922
    def _match_on(self, branch, revs):