##// END OF EJS Templates
notify: fix diffstat printing...
notify: fix diffstat printing notify.diff() keeps line breaks in the diff buffer before calling patch.diffstat(). patch.diffstat() however adds another line break when feeding diffstat input. The added extra empty line leads to erroneous diffstat output. This fix removes the line breaks in notify.diff() and adds it back to print them.

File last commit:

r6962:2af657ea default
r6979:a3fd4aa1 default
Show More
interhg.py
84 lines | 2.6 KiB | text/x-python | PythonLexer
OHASHI Hideya
interhg extension allows you to change changelog text like InterWiki.
r4817 # interhg.py - interhg
#
# Copyright 2007 OHASHI Hideya <ohachige@gmail.com>
#
Edward Lee
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)...
r5288 # Contributor(s):
# Edward Lee <edward.lee@engineering.uiuc.edu>
#
OHASHI Hideya
interhg extension allows you to change changelog text like InterWiki.
r4817 # This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.
#
# The `interhg' Mercurial extension allows you to change changelog and
# summary text just like InterWiki way.
#
# To enable this extension:
#
# [extensions]
# interhg =
#
Edward Lee
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)...
r5288 # These are some example patterns (link to bug tracking, etc.)
OHASHI Hideya
interhg extension allows you to change changelog text like InterWiki.
r4817 #
# [interhg]
Edward Lee
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)...
r5288 # 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>/
OHASHI Hideya
interhg extension allows you to change changelog text like InterWiki.
r4817 #
Edward Lee
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)...
r5288 # Add any number of names and patterns to match
OHASHI Hideya
interhg extension allows you to change changelog text like InterWiki.
r4817
import re
from mercurial.hgweb import hgweb_mod
Matt Mackall
templates: move filters to their own module...
r5976 from mercurial import templatefilters
Martin Geisler
i18n: mark strings for translation in interhg extension
r6962 from mercurial.i18n import _
OHASHI Hideya
interhg extension allows you to change changelog text like InterWiki.
r4817
Matt Mackall
templates: move filters to their own module...
r5976 orig_escape = templatefilters.filters["escape"]
OHASHI Hideya
interhg extension allows you to change changelog text like InterWiki.
r4817
interhg_table = []
def interhg_escape(x):
escstr = orig_escape(x)
Edward Lee
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)...
r5288 for regexp, format in interhg_table:
OHASHI Hideya
interhg extension allows you to change changelog text like InterWiki.
r4817 escstr = regexp.sub(format, escstr)
return escstr
Matt Mackall
templates: move filters to their own module...
r5976 templatefilters.filters["escape"] = interhg_escape
OHASHI Hideya
interhg extension allows you to change changelog text like InterWiki.
r4817
orig_refresh = hgweb_mod.hgweb.refresh
def interhg_refresh(self):
interhg_table[:] = []
Edward Lee
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)...
r5288 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:
Martin Geisler
i18n: mark strings for translation in interhg extension
r6962 self.repo.ui.warn(_("interhg: invalid pattern for %s: %s\n")
Edward Lee
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)...
r5288 % (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:
Martin Geisler
i18n: mark strings for translation in interhg extension
r6962 self.repo.ui.warn(_("interhg: invalid regexp for %s: %s\n")
Edward Lee
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)...
r5288 % (key, regexp))
OHASHI Hideya
interhg extension allows you to change changelog text like InterWiki.
r4817 return orig_refresh(self)
hgweb_mod.hgweb.refresh = interhg_refresh