Writing Mercurial Hooks For Fun and Profit!
Pradeepto Bhattacharya (~pradeepto) |
Mercurial is one of the leading SCM tools and any good SCM tool worth its salt has hooks that can be set up to do things like pre-commit verifications, run tests etc. Mercurial is written Python. Hg hooks can be written in Python.
Writing good commit messages is as important for a project as writing good code and one needs practice to write good commit messages (like anything else in life) and often developers do not take this bit very seriously and hence sometimes strict rules and policies need to be implemented. Using commit hooks, a project can enforce policies. This talk will try to solve this problem.
In this talk, I will cover the basics of what commit hooks are, fundamental concepts of Mercurial hooks, various terminologies relevant to Mercurial hooks and how Hg commit hooks are written. I will start from scratch and develop a simple but very useful Mercurial hook in Python that will do bunch of pre-commit validations. The hook I plan to showcase during the talk will be very close to a real life commit hook that I have used in production.
Talk Outline :
- The importance of good quality source code history.
- What are hooks?
- Why do we need hooks?
- Fundamental concepts of writing Hg hooks
- Simple example of Hg hook using Python
- More involved example of Hg hook (that would be close to a real commit hook already being used in production, it would verify the commit message based on certain rules)
- Question and Answers
Key takeaways from the talk would be the following :
- Understanding Mercurial Hook Concepts
- Writing a real life Mercurial Hook
- Understanding the importance of writing good commit messages
- Application of Python in tooling
Anyone with basic knowledge of Python and some experience with any modern SCM tool can attend this talk. It should be fairly easy to port the ideas from this talk to your choice of SCM tools.
Basics of Python, Any Version Control tools and concepts ( SVN, Git, Mercurial etc )
Pradeepto has been a long time contributor to Free and Open Source Software. He has contributed to the KDE project. He founded KDE India, the Indian chapter of KDE in 2005. He is currently serving as Director in the KDE e.V. Board. He has organised many KDE meet ups and conferences in India. He has also contributed to some other Open Source projects like NuPIC and Ops School Curriculum. He is speaks regularly at conferences and events. He has mentored many people in local Open Source communities and also at his job.
He developed desktop and mobile applications using C++/Qt/KDE in past. Since last few years he has been building tools using Ruby, Python and Chef to help Release and QA engineering teams. He has led a DevOps and QA teams for multiple clients. He has designed and implemented CI/CD pipelines using various tools. He is an expert in Continuous Integration, Continuous Deployment and Continuous Delivery.
He is currently the Director of Engineering - DevOps at Clogeny Technologies Pvt. Ltd, a MSys Company, based out of Pune, India. He lives in Pune with his wife.