# HG changeset patch # User Marcin Kuzminski # Date 1348414433 -7200 # Node ID 736678a8c881827981e862686227e4ea6f72c8e8 # Parent 6d9b3ade3051f49fb6875e8493a70446cf137664 #518 multiple issues patterns - added logging - some code cleanup - added example of wiki pattern to .ini file - updated contributors and changelog diff -r 6d9b3ade3051 -r 736678a8c881 CONTRIBUTORS --- a/CONTRIBUTORS Thu Sep 20 20:30:55 2012 -0400 +++ b/CONTRIBUTORS Sun Sep 23 17:33:53 2012 +0200 @@ -26,3 +26,4 @@ Dominik Ruf xpol Vincent Caron + Zachary Auclair \ No newline at end of file diff -r 6d9b3ade3051 -r 736678a8c881 development.ini --- a/development.ini Thu Sep 20 20:30:55 2012 -0400 +++ b/development.ini Sun Sep 23 17:33:53 2012 +0200 @@ -108,6 +108,16 @@ issue_prefix = # +## issue_pat, issue_server_link, issue_prefix can have suffixes to specify +## multiple patterns, to other issues server, wiki or others +## below an example how to create a wiki pattern +# #wiki-some-id -> https://mywiki.com/some-id + +#issue_pat_wiki = (?:wiki-)(.+) +#issue_server_link_wiki = https://mywiki.com/{id} +#issue_prefix_wiki = WIKI- + + ## instance-id prefix ## a prefix key for this instance used for cache invalidation when running ## multiple instances of rhodecode, make sure it's globally unique for diff -r 6d9b3ade3051 -r 736678a8c881 docs/changelog.rst --- a/docs/changelog.rst Thu Sep 20 20:30:55 2012 -0400 +++ b/docs/changelog.rst Sun Sep 23 17:33:53 2012 +0200 @@ -16,6 +16,7 @@ - #558 Added config file to hooks extra data - bumbped mercurial version to 2.3.1 +- #518 added possibility of specifing multiple patterns for issues fixes +++++ diff -r 6d9b3ade3051 -r 736678a8c881 production.ini --- a/production.ini Thu Sep 20 20:30:55 2012 -0400 +++ b/production.ini Sun Sep 23 17:33:53 2012 +0200 @@ -108,6 +108,16 @@ issue_prefix = # +## issue_pat, issue_server_link, issue_prefix can have suffixes to specify +## multiple patterns, to other issues server, wiki or others +## below an example how to create a wiki pattern +# #wiki-some-id -> https://mywiki.com/some-id + +#issue_pat_wiki = (?:wiki-)(.+) +#issue_server_link_wiki = https://mywiki.com/{id} +#issue_prefix_wiki = WIKI- + + ## instance-id prefix ## a prefix key for this instance used for cache invalidation when running ## multiple instances of rhodecode, make sure it's globally unique for diff -r 6d9b3ade3051 -r 736678a8c881 rhodecode/config/deployment.ini_tmpl --- a/rhodecode/config/deployment.ini_tmpl Thu Sep 20 20:30:55 2012 -0400 +++ b/rhodecode/config/deployment.ini_tmpl Sun Sep 23 17:33:53 2012 +0200 @@ -108,6 +108,16 @@ issue_prefix = # +## issue_pat, issue_server_link, issue_prefix can have suffixes to specify +## multiple patterns, to other issues server, wiki or others +## below an example how to create a wiki pattern +# #wiki-some-id -> https://mywiki.com/some-id + +#issue_pat_wiki = (?:wiki-)(.+) +#issue_server_link_wiki = https://mywiki.com/{id} +#issue_prefix_wiki = WIKI- + + ## instance-id prefix ## a prefix key for this instance used for cache invalidation when running ## multiple instances of rhodecode, make sure it's globally unique for diff -r 6d9b3ade3051 -r 736678a8c881 rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py Thu Sep 20 20:30:55 2012 -0400 +++ b/rhodecode/lib/helpers.py Sun Sep 23 17:33:53 2012 +0200 @@ -1007,19 +1007,23 @@ # allow multiple issue servers to be used valid_indices = [ - x.group(1) - for x in map(lambda x: re.match(r'issue_pat(.*)', x), conf.keys()) - if x and conf.has_key('issue_server_link'+x.group(1)) and conf.has_key('issue_prefix'+x.group(1)) - ] + x.group(1) + for x in map(lambda x: re.match(r'issue_pat(.*)', x), conf.keys()) + if x and 'issue_server_link%s' % x.group(1) in conf + and 'issue_prefix%s' % x.group(1) in conf + ] - #log.debug('found issue server suffixes ' + ','.join(valid_indices) + ' during valuation of: \n' + newtext) + log.debug('found issue server suffixes `%s` during valuation of: %s' + % (','.join(valid_indices), newtext)) for pattern_index in valid_indices: - ISSUE_PATTERN = conf.get('issue_pat'+pattern_index) - ISSUE_SERVER_LNK = conf.get('issue_server_link'+pattern_index) - ISSUE_PREFIX = conf.get('issue_prefix'+pattern_index) + ISSUE_PATTERN = conf.get('issue_pat%s' % pattern_index) + ISSUE_SERVER_LNK = conf.get('issue_server_link%s' % pattern_index) + ISSUE_PREFIX = conf.get('issue_prefix%s' % pattern_index) - #log.debug(ISSUE_PATTERN + ' ' + ISSUE_SERVER_LNK + ' ' + ISSUE_PREFIX) + log.debug('pattern suffix `%s` PAT:%s SERVER_LINK:%s PREFIX:%s' + % (pattern_index, ISSUE_PATTERN, ISSUE_SERVER_LNK, + ISSUE_PREFIX)) URL_PAT = re.compile(r'%s' % ISSUE_PATTERN) @@ -1048,9 +1052,8 @@ 'issue-prefix': ISSUE_PREFIX, 'serv': ISSUE_SERVER_LNK, } - newtext = URL_PAT.sub(url_func, newtext) - #log.debug('after '+pattern_index+':\n'+newtext) + log.debug('processed prefix:`%s` => %s' % (pattern_index, newtext)) # if we actually did something above if valid_indices: