 >         '''
 >         Send email via SMTP
 >         '''
->         log("Sending email to %s" % smtp_mailinglist)
->         self.connection = smtplib.SMTP(self.smtp_host)
+>         utilities.log("Sending email to %s" % smtp_mailinglist)
+>         try:
+>             self.connection = smtplib.SMTP(self.smtp_host)
+>         except Exception as __error:
+>             logging.error(u'SMTPlib %s contacting server %s:%s' % (repr(__error),
+>                 self.smtp_host, self.smtp_port))
+>             logging.error(u'Message delivery failed.')
+>             return False
 >         try:
 >             # identify ourselves, prompting server for supported features
 >             self.connection.ehlo()

1c1
< #! /usr/bin/env python
---
> #!/usr/bin/env python
2a3,9
> '''
> This is a fork of ICIR.org git-notifier that implements colorized diff support
> plus some other nice things.
> Please refer to https://github.com/tb0hdan/GIT-Notifier for more detail.
> '''
> 
> # pylint: disable=C0103,C0302
10,18c17,53
< import time
< 
< VERSION   = "0.3-16"  # Filled in automatically.

>                 __result_data = '%s\n%s' % (__noformat_data,
>                         self.formatDiff(__result_data))
>                 return __result_data
377,383c687
<             print >>out, line
< 
<     print >>out, Separator
< 
<     if tname:
<         for line in open(tname):
<             print >>out, line,
---
>             return None
385,543c689,943
<     print >>out, footer
< 
<     if Config.debug:
<         print >>out, "-- "
<         print >>out, "debug: show_cmd = git %s" % show_cmd
<         print >>out, "debug: diff_cmd = git %s" % diff_cmd
< 
<     sendMail(out, fname)
< 
< # Sends notification for a specific revision.
< def commit(current, rev, force=False, subject_head=None):
<     if rev in current.reported and not force:
<         # Already reported in this run of the script.
<         log("Flagged revision %s for notification, but already reported this time" % rev)
<         return
< 
<     log("New revision %s" % rev)
<     current.reported.add(rev)
< 
<     heads = [head.split()[-1] for head in git("branch --contains=%s" % rev)]
<     if not subject_head:
<         subject_head = ",".join(heads)
< 
<     merge_diff = "--cc"
< 
<     for head in heads:
<         if head in Config.allchanges or head in Config.mergediffs:
<             merge_diff = "-m"
< 
<     subject = git("show '--pretty=format:%%s (%%h)' -s %s" % rev)
<     subject = "%s: %s" % (subject_head, subject[0])
< 
<     show_cmd = "show -s --no-color --find-copies-harder --pretty=medium %s" % rev
<     diff_cmd = "diff-tree --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol %s %s" % (merge_diff, rev)
< 
<     sendChangeMail(rev, subject, heads, show_cmd, diff_cmd)
< 
< # Sends a diff between two revisions.
< #
< # Only used in manual mode now.
< def diff(head, first, last):
<     # We record a pseudo-revision to avoid sending the same diff twice.
<     rev = "%s-%s" % (head, last)
<     if not rev in current.diffs:
<         log("New diff revision %s" % rev)
<         current.diffs.add(rev)
< 
<     log("Diffing %s..%s" % (first, last))
< 
<     subject = git("show '--pretty=format:%%s (%%h)' -s %s" % last)
<     subject = "%s diff: %s" % (head, subject[0])
< 
<     heads = [head]
< 
<     show_cmd = "show -s --no-color --find-copies-harder --pretty=medium %s" % last
<     diff_cmd = "diff --patch-with-stat -m --no-color --find-copies-harder --ignore-space-at-eol %s %s" % (first, last)
< 
<     sendChangeMail(last, subject, heads, show_cmd, diff_cmd)
< 
< # Sends pair-wise diffs for a path of revisions. Also records all revision on
< # the path as seen.
< #
< # Only used in manual mode now.
< def diffPath(head, revs):
<     last = None
< 
<     for rev in revs:
<         if last:
<             diff(head, last, rev)
<         last = rev
< 
< # Sends a commit notifications for a set of revisions.
< def reportPath(current, revs, force=False, subject_head=None):
<     if not revs:
<         return
< 
<     # Sort updates by time.
<     revs = git("rev-list --no-walk --reverse --date-order %s" % " ".join(revs))
< 
<     for rev in revs:
<         commit(current, rev, force=force, subject_head=subject_head)
< 
< # Sends a summary mail for a set of revisions.
< def headMoved(head, path):
<     log("Head moved: %s -> %s" % (head, path[-1]))
< 
<     subject = git("show '--pretty=format:%%s (%%h)' -s %s" % path[-1])
< 
<     (out, fname) = generateMailHeader("%s's head updated: %s" % (head, subject[0]))
< 
<     print >>out, "Branch '%s' now includes:" % head
<     print >>out, ""
< 
<     for rev in path:
<         print >>out, "    ", git("show -s --pretty=oneline --abbrev-commit %s" % rev)[0]
< 
<     sendMail(out, fname)
< 
< Config = GitConfig(sys.argv[1:])
< 
< log("Running for %s" % os.getcwd())
< 
< if Config.debug:
<     for (name, arg, default, help) in Options:
<         print >>sys.stderr, "[Option %s: %s]" % (name, Config.__dict__[name])
< 
< cache = State()
< 
< if os.path.exists(CacheFile):
<     cache.readFrom(CacheFile)
<     report = (not Config.updateonly)
< else:
<     log("Initial run. Not generating any mails, just recording current state.")
<     report = False
< 
< current = getCurrent()
< 
< if Config.diff:
<     # Manual diff mode. The argument must be of the form "[old-rev..]new-rev".
<     path = [rev.strip() for rev in Config.diff.split("..")]
<     if len(path) == 1:
<         path = ("%s~2" % path[0], path[0]) # sic! ~2.
<     else:
<         path = ("%s~1" % path[0], path[1])
< 
<     revs = git(["rev-list", "--reverse --date-order", path[1], "^%s" % path[0]])
< 
<     diffPath("<manual-diff>", revs)
< 
<     sys.exit(0)
< 
< if Config.manual:
<     # Manual report mode. The argument must be of the form "[old-rev..]new-rev".
<     path = [rev.strip() for rev in Config.manual.split("..")]
<     if len(path) == 1:
<         path = ("%s~1" % path[0], path[0])
< 
<     revs = git(["rev-list", "--reverse --date-order", path[1], "^%s" % path[0]])
<     reportPath(current, revs, force=True)
< 
<     sys.exit(0)
< 
< if report:
<     # Check for changes to the set of heads.
<     old = set(cache.heads.keys())
<     new = set(current.heads.keys())
< 
<     for head in (new - old):
<         entryAdded("branch", head, current.heads[head])
< 
<     for head in (old - new):
<         entryDeleted("branch", head)
< 
<     stable_heads = new & old
<     Config.allchanges = Config.allchanges & stable_heads
< 
<     # Check tags.
<     old = set(cache.tags.keys())
<     new = set(current.tags.keys())
---
> class PrettyHTML(object):
>     '''
>     Simple class to make 'git show' message look prettier
