[Python-checkins] r88837 - in tracker/instances/python-dev/extensions: local_replace.py test/test_local_replace.py

ezio.melotti python-checkins at python.org
Tue May 24 23:11:36 CEST 2011


Author: ezio.melotti
Date: Tue May 24 23:11:36 2011
New Revision: 88837
Log:
Link to a specific line when :NNN is added after a file name. Also update and add more tests.
Modified:
 tracker/instances/python-dev/extensions/local_replace.py
 tracker/instances/python-dev/extensions/test/test_local_replace.py
Modified: tracker/instances/python-dev/extensions/local_replace.py
==============================================================================
--- tracker/instances/python-dev/extensions/local_replace.py	(original)
+++ tracker/instances/python-dev/extensions/local_replace.py	Tue May 24 23:11:36 2011
@@ -21,6 +21,23 @@
 ]
 '''
 
+def make_file_link(match):
+ baseurl = 'http://hg.python.org/cpython/file/default/'
+ sep = match.group('sep')
+ path = match.group('path')
+ lnum = match.group('lnum') or '' # the match includes the ':'
+ if not path.endswith('/'):
+ # files without and with line number
+ if not lnum:
+ return '<a href="%s%s">%s%s</a>' % (baseurl, path, sep, path)
+ else:
+ return '<a href="%s%s#l%s">%s%s%s</a>' % (baseurl, path, lnum[1:],
+ sep, path, lnum)
+ else:
+ # dirs
+ return '<a href="%s%s">%s%s</a>%s' % (baseurl, path, sep, path, lnum)
+
+
 substitutions = [
 # r12345, r 12345, rev12345, rev 12345, revision12345, revision 12345
 (re.compile(r'\b(?<![/?&;])(?P<revstr>r(ev(ision)?)?\s*)(?P<revision>\d+)'),
@@ -32,11 +49,11 @@
 (re.compile(r'\b(?<![/?&;])(?P<revision>[a-fA-F0-9]{12})\b'),
 r'<a href="http://hg.python.org/lookup/\g<revision>">\g<revision></a>'),
 
- # Lib/somefile.py, Modules/somemodule.c, Doc/somedocfile.rst, ...
+ # Lib/somefile.py, Lib/somefile.py:123, Modules/somemodule.c:123, ...
 (re.compile(r'(?P<sep>(?<!\w/)|(?<!\w)/)(?P<path>(?:Demo|Doc|Grammar|'
 r'Include|Lib|Mac|Misc|Modules|Parser|PC|PCbuild|Python|'
- 'RISCOS|Tools|Objects)/[-.a-zA-Z0-9_/]+[a-zA-Z0-9]/?)'),
- r'<a href="http://hg.python.org/cpython/file/default/\g<path>">\g<sep>\g<path></a>'),
+ r'RISCOS|Tools|Objects)/[-.\w/]+[a-zA-Z0-9]/?)(?P<lnum>:\d{1,5})?'),
+ make_file_link),
 ]
 
 # if the issue number is too big the db will explode -- limit it to 7 digits
Modified: tracker/instances/python-dev/extensions/test/test_local_replace.py
==============================================================================
--- tracker/instances/python-dev/extensions/test/test_local_replace.py	(original)
+++ tracker/instances/python-dev/extensions/test/test_local_replace.py	Tue May 24 23:11:36 2011
@@ -47,19 +47,19 @@
 test_strings = [
 ## r12345, r 12345, rev12345, rev 12345, revision12345, revision 12345
 ('r222 ',
- '<a href="http://svn.python.org/view?rev=222&view=rev">r222</a> '),
+ '<a href="http://hg.python.org/lookup/r222">r222</a> '),
 (' r222 ',
- ' <a href="http://svn.python.org/view?rev=222&view=rev">r222</a> '),
+ ' <a href="http://hg.python.org/lookup/r222">r222</a> '),
 (' r 222 ',
- ' <a href="http://svn.python.org/view?rev=222&view=rev">r 222</a> '),
+ ' <a href="http://hg.python.org/lookup/r222">r 222</a> '),
 (' rev222 ',
- ' <a href="http://svn.python.org/view?rev=222&view=rev">rev222</a> '),
+ ' <a href="http://hg.python.org/lookup/r222">rev222</a> '),
 (' rev 222 ',
- ' <a href="http://svn.python.org/view?rev=222&view=rev">rev 222</a> '),
+ ' <a href="http://hg.python.org/lookup/r222">rev 222</a> '),
 (' revision222 ',
- ' <a href="http://svn.python.org/view?rev=222&view=rev">revision222</a> '),
+ ' <a href="http://hg.python.org/lookup/r222">revision222</a> '),
 (' revision 222 ',
- ' <a href="http://svn.python.org/view?rev=222&view=rev">revision 222</a> '),
+ ' <a href="http://hg.python.org/lookup/r222">revision 222</a> '),
 ('wordthatendswithr 222',
 'wordthatendswithr 222'),
 
@@ -96,17 +96,31 @@
 
 ## Lib/somefile.py, Modules/somemodule.c, Doc/somedocfile.rst, ...
 ('Lib/cgi.py',
- '<a href="http://svn.python.org/view/python/branches/py3k/Lib/cgi.py">Lib/cgi.py</a>'),
+ '<a href="http://hg.python.org/cpython/file/default/Lib/cgi.py">Lib/cgi.py</a>'),
 ('/Lib/cgi.py',
- '<a href="http://svn.python.org/view/python/branches/py3k/Lib/cgi.py">/Lib/cgi.py</a>'),
+ '<a href="http://hg.python.org/cpython/file/default/Lib/cgi.py">/Lib/cgi.py</a>'),
 ('see Lib/cgi.py.',
- 'see <a href="http://svn.python.org/view/python/branches/py3k/Lib/cgi.py">Lib/cgi.py</a>.'),
+ 'see <a href="http://hg.python.org/cpython/file/default/Lib/cgi.py">Lib/cgi.py</a>.'),
 ('see /Lib/cgi.py.',
- 'see <a href="http://svn.python.org/view/python/branches/py3k/Lib/cgi.py">/Lib/cgi.py</a>.'),
+ 'see <a href="http://hg.python.org/cpython/file/default/Lib/cgi.py">/Lib/cgi.py</a>.'),
 ('(Lib/cgi.py)',
- '(<a href="http://svn.python.org/view/python/branches/py3k/Lib/cgi.py">Lib/cgi.py</a>)'),
+ '(<a href="http://hg.python.org/cpython/file/default/Lib/cgi.py">Lib/cgi.py</a>)'),
 ('(/Lib/cgi.py)',
- '(<a href="http://svn.python.org/view/python/branches/py3k/Lib/cgi.py">/Lib/cgi.py</a>)'),
+ '(<a href="http://hg.python.org/cpython/file/default/Lib/cgi.py">/Lib/cgi.py</a>)'),
+ ('/Lib/http',
+ '<a href="http://hg.python.org/cpython/file/default/Lib/http">/Lib/http</a>'),
+ ('/Lib/http/',
+ '<a href="http://hg.python.org/cpython/file/default/Lib/http/">/Lib/http/</a>'),
+
+ ## Lib/somefile.py:123, Modules/somemodule.c:123, ...
+ ('see Lib/cgi.py:123,',
+ 'see <a href="http://hg.python.org/cpython/file/default/Lib/cgi.py#l123">Lib/cgi.py:123</a>,'),
+ ('see Lib/cgi.py: foo',
+ 'see <a href="http://hg.python.org/cpython/file/default/Lib/cgi.py">Lib/cgi.py</a>: foo'),
+ ('see Lib/cgi.py: 123',
+ 'see <a href="http://hg.python.org/cpython/file/default/Lib/cgi.py">Lib/cgi.py</a>: 123'),
+ ('/Lib/http/:123',
+ '<a href="http://hg.python.org/cpython/file/default/Lib/http/">/Lib/http/</a>:123'),
 
 ## URLs
 ('http://svn.python.org/view/python/tags/r265 ',


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /