We have at least three types with a close() and a release() method
where the close() method is supposed to be called on success and the
release() method is supposed to be called last, whether successful or
not. Two of them (transaction and dirstateguard) already have
identical implementations of enter and exit. Let's extract a
base class for this, so we reuse the code and so the third type
(transactionmanager) can also be used as a context manager.
Details
Details
- Reviewers
indygreg - Group Reviewers
hg-reviewers - Commits
- rHGbbbbd3c30bfc: util: add base class for transactional context managers
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
Event Timeline
mercurial/util.py | ||
---|---|---|
597–601 | Sounds good. I had heard you mention abc before, but I was simply too lazy to bother checking how to do it. Now that I have an example: done! Let me know how it looks. We should probably do that for matchers too, in case someone feels like it... |
How do you feel about changing this to use abc.ABCMeta so the interface is enforced as type creation time? I'm doing this in D332 and people seem to be on board.