/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/plugins/email/emailer.py

Use new context stuff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
199
199
        Depending on the configuration, this will either use smtplib, or it
200
200
        will call out to the 'mail' program.
201
201
        """
202
 
        self.branch.lock_read()
203
 
        self.repository.lock_read()
204
 
        try:
 
202
        with self.branch.lock_read(), self.repository.lock_read():
205
203
            # Do this after we have locked, to make things faster.
206
204
            self._setup_revision_and_revno()
207
205
            mailer = self.mailer()
209
207
                self._send_using_smtplib()
210
208
            else:
211
209
                self._send_using_process()
212
 
        finally:
213
 
            self.repository.unlock()
214
 
            self.branch.unlock()
215
210
 
216
211
    def _send_using_process(self):
217
212
        """Spawn a 'mail' subprocess to send the email."""