comparison hgext/bugzilla.py @ 2199:f1986a61ccff

move stringio class from bugzilla extension into templater module.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Thu, 04 May 2006 12:02:32 -0700
parents 5de8b44f0446
children f15056b29472
comparison
equal deleted inserted replaced
2198:564034552f7f 2199:f1986a61ccff
41 # baseurl = http://hgserver/... # root of hg web site for browsing commits 41 # baseurl = http://hgserver/... # root of hg web site for browsing commits
42 42
43 from mercurial.demandload import * 43 from mercurial.demandload import *
44 from mercurial.i18n import gettext as _ 44 from mercurial.i18n import gettext as _
45 from mercurial.node import * 45 from mercurial.node import *
46 demandload(globals(), 'cStringIO mercurial:templater,util os re time') 46 demandload(globals(), 'mercurial:templater,util os re time')
47 47
48 try: 48 try:
49 import MySQLdb 49 import MySQLdb
50 except ImportError: 50 except ImportError:
51 raise util.Abort(_('python mysql support not available')) 51 raise util.Abort(_('python mysql support not available'))
239 break 239 break
240 root = root[c+1:] 240 root = root[c+1:]
241 count -= 1 241 count -= 1
242 return root 242 return root
243 243
244 class stringio(object):
245 '''wrap cStringIO.'''
246 def __init__(self):
247 self.fp = cStringIO.StringIO()
248
249 def write(self, *args):
250 for a in args:
251 self.fp.write(a)
252
253 write_header = write
254
255 def getvalue(self):
256 return self.fp.getvalue()
257
258 mapfile = self.ui.config('bugzilla', 'style') 244 mapfile = self.ui.config('bugzilla', 'style')
259 tmpl = self.ui.config('bugzilla', 'template') 245 tmpl = self.ui.config('bugzilla', 'template')
260 sio = stringio() 246 sio = templater.stringio()
261 t = templater.changeset_templater(self.ui, self.repo, mapfile, sio) 247 t = templater.changeset_templater(self.ui, self.repo, mapfile, sio)
262 if not mapfile and not tmpl: 248 if not mapfile and not tmpl:
263 tmpl = _('changeset {node|short} in repo {root} refers ' 249 tmpl = _('changeset {node|short} in repo {root} refers '
264 'to bug {bug}.\ndetails:\n\t{desc|tabindent}') 250 'to bug {bug}.\ndetails:\n\t{desc|tabindent}')
265 if tmpl: 251 if tmpl: