[PATCH 3 of 3] interhg: mark extension as deprecated
Angel Ezquerra
angel.ezquerra at gmail.com
Sat Feb 9 10:02:04 UTC 2013
# HG changeset patch
# User Angel Ezquerra <angel.ezquerra at gmail.com>
# Date 1360404042 -3600
# Node ID a10aef05062fc23df412e7ad03e5ee845de3aaea
# Parent 0ca84e16d89af5c0125d19e741605caca09da49f
interhg: mark extension as deprecated
Most of its functionality can be achieved with the builtin websub filter.
diff --git a/hgext/interhg.py b/hgext/interhg.py
--- a/hgext/interhg.py
+++ b/hgext/interhg.py
@@ -8,7 +8,12 @@
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
-'''expand expressions into changelog and summaries
+'''expand expressions into changelog and summaries (DEPRECATED)
+
+This extension is deprecated. Rather than using this extension
+you should move the contents of your [interhg] section into
+the [websub] section. The behavior is not exactly the same
+though (the differences are explained below).
This extension allows the use of a special syntax in summaries, which
will be automatically expanded into links or any other arbitrary
@@ -21,63 +26,17 @@
issues = s!issue(\\d+)!<a href="http://bts/issue\\1">issue\\1</a>!
bugzilla = s!((?:bug|b=|(?=#?\\d{4,}))(?:\\s*#?)(\\d+))!<a..=\\2">\\1</a>!i
boldify = s!(^|\\s)#(\\d+)\\b! <b>#\\2</b>!
+
+The builtin [websub] section supports the same syntax as the interhg
+extension. The difference is that where interhg would apply the
+replacement expressions on all the hgweb output, the websub patterns
+are only applied to full changeset descriptions. In addition the
+websub expressions can be different for different repositories.
'''
-import re
-from mercurial.hgweb import hgweb_mod
-from mercurial import templatefilters, extensions
-from mercurial.i18n import _
-
testedwith = 'internal'
-interhg_table = []
-def uisetup(ui):
- orig_escape = templatefilters.filters["escape"]
-
- def interhg_escape(x):
- escstr = orig_escape(x)
- for regexp, format in interhg_table:
- escstr = regexp.sub(format, escstr)
- return escstr
-
- templatefilters.filters["escape"] = interhg_escape
-
-def interhg_refresh(orig, self, *args, **kwargs):
- interhg_table[:] = []
- for key, pattern in self.repo.ui.configitems('interhg'):
- # grab the delimiter from the character after the "s"
- unesc = pattern[1]
- delim = re.escape(unesc)
-
- # identify portions of the pattern, taking care to avoid escaped
- # delimiters. the replace format and flags are optional, but delimiters
- # are required.
- match = re.match(r'^s%s(.+)(?:(?<=\\\\)|(?<!\\))%s(.*)%s([ilmsux])*$'
- % (delim, delim, delim), pattern)
- if not match:
- self.repo.ui.warn(_("interhg: invalid pattern for %s: %s\n")
- % (key, pattern))
- continue
-
- # we need to unescape the delimiter for regexp and format
- delim_re = re.compile(r'(?<!\\)\\%s' % delim)
- regexp = delim_re.sub(unesc, match.group(1))
- format = delim_re.sub(unesc, match.group(2))
-
- # the pattern allows for 6 regexp flags, so set them if necessary
- flagin = match.group(3)
- flags = 0
- if flagin:
- for flag in flagin.upper():
- flags |= re.__dict__[flag]
-
- try:
- regexp = re.compile(regexp, flags)
- interhg_table.append((regexp, format))
- except re.error:
- self.repo.ui.warn(_("interhg: invalid regexp for %s: %s\n")
- % (key, regexp))
- return orig(self, *args, **kwargs)
-
-extensions.wrapfunction(hgweb_mod.hgweb, 'refresh', interhg_refresh)
+def reposetup(ui, repo):
+ for name, value in repo.ui.configitems('interhg'):
+ repo.ui.setconfig('websub', name, value)
More information about the Mercurial-devel
mailing list