Details
Details
- Reviewers
pulkit - Group Reviewers
hg-reviewers - Commits
- rHG46b55f279571: notify: adapt to new location of email module's errors
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
( )
pulkit |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
import time | import time | ||||
from mercurial.i18n import _ | from mercurial.i18n import _ | ||||
from mercurial import ( | from mercurial import ( | ||||
error, | error, | ||||
logcmdutil, | logcmdutil, | ||||
mail, | mail, | ||||
patch, | patch, | ||||
pycompat, | |||||
registrar, | registrar, | ||||
util, | util, | ||||
) | ) | ||||
from mercurial.utils import ( | from mercurial.utils import ( | ||||
dateutil, | dateutil, | ||||
stringutil, | stringutil, | ||||
) | ) | ||||
if pycompat.ispy3: | |||||
import email.errors as emailerrors | |||||
else: | |||||
emailerrors = email.Errors | |||||
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for | ||||
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should | # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should | ||||
# be specifying the version(s) of Mercurial they are tested with, or | # be specifying the version(s) of Mercurial they are tested with, or | ||||
# leave the attribute unspecified. | # leave the attribute unspecified. | ||||
testedwith = 'ships-with-hg-core' | testedwith = 'ships-with-hg-core' | ||||
configtable = {} | configtable = {} | ||||
configitem = registrar.configitem(configtable) | configitem = registrar.configitem(configtable) | ||||
if len(subs) == 0: | if len(subs) == 0: | ||||
self.ui.debug('notify: no subscribers to selected repo ' | self.ui.debug('notify: no subscribers to selected repo ' | ||||
'and revset\n') | 'and revset\n') | ||||
return | return | ||||
p = emailparser.Parser() | p = emailparser.Parser() | ||||
try: | try: | ||||
msg = p.parsestr(data) | msg = p.parsestr(data) | ||||
except email.Errors.MessageParseError as inst: | except emailerrors.MessageParseError as inst: | ||||
raise error.Abort(inst) | raise error.Abort(inst) | ||||
# store sender and subject | # store sender and subject | ||||
sender, subject = msg['From'], msg['Subject'] | sender, subject = msg['From'], msg['Subject'] | ||||
del msg['From'], msg['Subject'] | del msg['From'], msg['Subject'] | ||||
if not msg.is_multipart(): | if not msg.is_multipart(): | ||||
# create fresh mime message from scratch | # create fresh mime message from scratch |