bool_from_store,
int_from_store,
)
+import socket
+import sys
+import json
class IrkerSender(object):
'%(brown)s%(url)s%(reset)s' % fields)
return text
- def body(self):
- from bzrlib import log
-
- rev1 = rev2 = self.revno
- if rev1 == 0:
- rev1 = None
- rev2 = None
-
- # use 'replace' so that we don't abort if trying to write out
- # in e.g. the default C locale.
-
- # Following bzr-email, we use StringIO.StringIO to minimise possible
- # unicode issues.
- from StringIO import StringIO
- outf = StringIO()
-
- lf = log.log_formatter('line',
- show_ids=True,
- to_file=outf
- )
-
- if len(self.revision.parent_ids) <= 1:
- # This is not a merge, so we can special case the display of one
- # revision, and not have to encur the show_log overhead.
- lr = log.LogRevision(self.revision, self.revno, 0, None)
- lf.log_revision(lr)
- else:
- # let the show_log code figure out what revisions need to be
- # displayed, as this is a merge
- log.show_log(self.branch,
- lf,
- start_revision=rev1,
- end_revision=rev2,
- verbose=True
- )
-
- return outf.getvalue()
-
def url(self):
"""What URL to display in the subject of the mail"""
url = self.config.get('irker_url')
# Vaues taken from irker's irkerhook.py
if colour_style == 'ANSI':
colours = {
- 'bold': '\x1b[1m'
- 'green': '\x1b[1;32m'
- 'blue': '\x1b[1;34m'
- 'red': '\x1b[1;31m'
- 'yellow': '\x1b[1;33m'
- 'brown': '\x1b[33m'
- 'magenta': '\x1b[35m'
- 'cyan': '\x1b[36m'
- 'reset': '\x1b[0m'
+ 'bold': '\x1b[1m',
+ 'green': '\x1b[1;32m',
+ 'blue': '\x1b[1;34m',
+ 'red': '\x1b[1;31m',
+ 'yellow': '\x1b[1;33m',
+ 'brown': '\x1b[33m',
+ 'magenta': '\x1b[35m',
+ 'cyan': '\x1b[36m',
+ 'reset': '\x1b[0m',
}
elif colour_style == 'mIRC':
colours = {
- 'bold': '\x02'
- 'green': '\x0303'
- 'blue': '\x0302'
- 'red': '\x0305'
- 'yellow': '\x0307'
- 'brown': '\x0305'
- 'magenta': '\x0306'
- 'cyan': '\x0310'
- 'reset': '\x0F'
+ 'bold': '\x02',
+ 'green': '\x0303',
+ 'blue': '\x0302',
+ 'red': '\x0305',
+ 'yellow': '\x0307',
+ 'brown': '\x0305',
+ 'magenta': '\x0306',
+ 'cyan': '\x0310',
+ 'reset': '\x0F',
}
return colours
def project(self):
- projet = self.config.get('irker_project')
+ project = self.config.get('irker_project')
if project is None:
project = 'No Project name set'
return project
"""
self.branch.lock_read()
self.repository.lock_read()
+ # These should become configurable at some point
+ default_server = 'localhost'
+ IRKER_PORT = 6659
try:
# Do this after we have locked, to make things faster.
self._setup_revision_and_revno()
+ channels = self.config.get('irker_channels')
+ msg = unicode(self._format())
+ # We rely on the server truncating, rather than trying to be
+ # too fancy here
+ message = json.dumps({"to": channels, "privmsg": msg})
+ if channels:
+ # We assume tcp, since I'm lazy, so we just grab that bit
+ # of irker's code
+ try:
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sock.connect((default_server, IRKER_PORT))
+ sock.sendall(message + "\n")
+ except socket.error, e:
+ sys.stderr.write("%s\n" % e)
+ finally:
+ sock.close()
finally:
self.repository.unlock()
self.branch.unlock()