##// END OF EJS Templates
Allowing multiple issue servers to be autolinked in the changeset view;...
Zachary Auclair -
r2865:6d9b3ade beta
parent child Browse files
Show More
@@ -1000,16 +1000,28 def urlify_commit(text_, repository=None
1000 return ''.join(links)
1000 return ''.join(links)
1001
1001
1002 # urlify changesets - extrac revisions and make link out of them
1002 # urlify changesets - extrac revisions and make link out of them
1003 text_ = urlify_changesets(escaper(text_), repository)
1003 newtext = urlify_changesets(escaper(text_), repository)
1004
1004
1005 try:
1005 try:
1006 conf = config['app_conf']
1006 conf = config['app_conf']
1007
1007
1008 URL_PAT = re.compile(r'%s' % conf.get('issue_pat'))
1008 # allow multiple issue servers to be used
1009 valid_indices = [
1010 x.group(1)
1011 for x in map(lambda x: re.match(r'issue_pat(.*)', x), conf.keys())
1012 if x and conf.has_key('issue_server_link'+x.group(1)) and conf.has_key('issue_prefix'+x.group(1))
1013 ]
1014
1015 #log.debug('found issue server suffixes ' + ','.join(valid_indices) + ' during valuation of: \n' + newtext)
1009
1016
1010 if URL_PAT:
1017 for pattern_index in valid_indices:
1011 ISSUE_SERVER_LNK = conf.get('issue_server_link')
1018 ISSUE_PATTERN = conf.get('issue_pat'+pattern_index)
1012 ISSUE_PREFIX = conf.get('issue_prefix')
1019 ISSUE_SERVER_LNK = conf.get('issue_server_link'+pattern_index)
1020 ISSUE_PREFIX = conf.get('issue_prefix'+pattern_index)
1021
1022 #log.debug(ISSUE_PATTERN + ' ' + ISSUE_SERVER_LNK + ' ' + ISSUE_PREFIX)
1023
1024 URL_PAT = re.compile(r'%s' % ISSUE_PATTERN)
1013
1025
1014 def url_func(match_obj):
1026 def url_func(match_obj):
1015 pref = ''
1027 pref = ''
@@ -1027,6 +1039,7 def urlify_commit(text_, repository=None
1027 url = url.replace('{repo}', repository)
1039 url = url.replace('{repo}', repository)
1028 repo_name = repository.split(URL_SEP)[-1]
1040 repo_name = repository.split(URL_SEP)[-1]
1029 url = url.replace('{repo_name}', repo_name)
1041 url = url.replace('{repo_name}', repo_name)
1042
1030 return tmpl % {
1043 return tmpl % {
1031 'pref': pref,
1044 'pref': pref,
1032 'cls': 'issue-tracker-link',
1045 'cls': 'issue-tracker-link',
@@ -1036,8 +1049,11 def urlify_commit(text_, repository=None
1036 'serv': ISSUE_SERVER_LNK,
1049 'serv': ISSUE_SERVER_LNK,
1037 }
1050 }
1038
1051
1039 newtext = URL_PAT.sub(url_func, text_)
1052 newtext = URL_PAT.sub(url_func, newtext)
1053 #log.debug('after '+pattern_index+':\n'+newtext)
1040
1054
1055 # if we actually did something above
1056 if valid_indices:
1041 if link_:
1057 if link_:
1042 # wrap not links into final link => link_
1058 # wrap not links into final link => link_
1043 newtext = linkify_others(newtext, link_)
1059 newtext = linkify_others(newtext, link_)
@@ -1047,7 +1063,7 def urlify_commit(text_, repository=None
1047 log.error(traceback.format_exc())
1063 log.error(traceback.format_exc())
1048 pass
1064 pass
1049
1065
1050 return text_
1066 return newtext
1051
1067
1052
1068
1053 def rst(source):
1069 def rst(source):
General Comments 0
You need to be logged in to leave comments. Login now