hgext/bugzilla.py
changeset 2218 afe24f5b7a9e
parent 2192 2be3ac7abc21
child 2219 ec82cff7d2c4
equal deleted inserted replaced
2192:2be3ac7abc21 2218:afe24f5b7a9e
    42 from mercurial.demandload import *
    42 from mercurial.demandload import *
    43 from mercurial.i18n import gettext as _
    43 from mercurial.i18n import gettext as _
    44 from mercurial.node import *
    44 from mercurial.node import *
    45 demandload(globals(), 'cStringIO mercurial:templater,util os re time')
    45 demandload(globals(), 'cStringIO mercurial:templater,util os re time')
    46 
    46 
    47 try:
    47 MySQLdb = None
    48     import MySQLdb
       
    49 except ImportError:
       
    50     raise util.Abort(_('python mysql support not available'))
       
    51 
    48 
    52 def buglist(ids):
    49 def buglist(ids):
    53     return '(' + ','.join(map(str, ids)) + ')'
    50     return '(' + ','.join(map(str, ids)) + ')'
    54 
    51 
    55 class bugzilla_2_16(object):
    52 class bugzilla_2_16(object):
   273 
   270 
   274 def hook(ui, repo, hooktype, node=None, **kwargs):
   271 def hook(ui, repo, hooktype, node=None, **kwargs):
   275     '''add comment to bugzilla for each changeset that refers to a
   272     '''add comment to bugzilla for each changeset that refers to a
   276     bugzilla bug id. only add a comment once per bug, so same change
   273     bugzilla bug id. only add a comment once per bug, so same change
   277     seen multiple times does not fill bug with duplicate data.'''
   274     seen multiple times does not fill bug with duplicate data.'''
       
   275     try:
       
   276         import MySQLdb as mysql
       
   277         global MySQLdb
       
   278         MySQLdb = mysql
       
   279     except ImportError, err:
       
   280         raise util.Abort(_('python mysql support not available: %s') % err)
       
   281 
   278     if node is None:
   282     if node is None:
   279         raise util.Abort(_('hook type %s does not pass a changeset id') %
   283         raise util.Abort(_('hook type %s does not pass a changeset id') %
   280                          hooktype)
   284                          hooktype)
   281     try:
   285     try:
   282         bz = bugzilla(ui, repo)
   286         bz = bugzilla(ui, repo)