comparison hgext/schemes.py @ 31191:150cd5125722

schemes: move re construction to module-level and python3-ify This makes the schemes extension load correctly in Python 3.
author Augie Fackler <raf@durin42.com>
date Fri, 03 Mar 2017 13:25:30 -0500
parents 7a3e67bfa417
children 198cd5ad9db8
comparison
equal deleted inserted replaced
31190:27e3b66ec7c5 31191:150cd5125722
61 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should 61 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
62 # be specifying the version(s) of Mercurial they are tested with, or 62 # be specifying the version(s) of Mercurial they are tested with, or
63 # leave the attribute unspecified. 63 # leave the attribute unspecified.
64 testedwith = 'ships-with-hg-core' 64 testedwith = 'ships-with-hg-core'
65 65
66 _partre = re.compile(r'\{(\d+)\}'.encode(u'latin1'))
66 67
67 class ShortRepository(object): 68 class ShortRepository(object):
68 def __init__(self, url, scheme, templater): 69 def __init__(self, url, scheme, templater):
69 self.scheme = scheme 70 self.scheme = scheme
70 self.templater = templater 71 self.templater = templater
71 self.url = url 72 self.url = url
72 try: 73 try:
73 self.parts = max(map(int, re.findall(r'\{(\d+)\}', self.url))) 74 self.parts = max(map(int, _partre.findall(self.url)))
74 except ValueError: 75 except ValueError:
75 self.parts = 0 76 self.parts = 0
76 77
77 def __repr__(self): 78 def __repr__(self):
78 return '<ShortRepository: %s>' % self.scheme 79 return '<ShortRepository: %s>' % self.scheme