mercurialmercurial-hook

Stop users pushing to stable branch in mercurial


I'm just starting to use Mercurial as a source control system. I was thinking of using the workflow similar to the one outlined here: http://stevelosh.com/blog/2010/05/mercurial-workflows-stable-default/. Basically, have two branches, one 'Stable' and one 'Development'. All development will be done on the 'Development' branch, and only merged into the 'Stable' branch when tested and ready for release.

o | v2.0
|\|
| o added new feature
o | V1.0
|\|
| o added new feature
| |
| o fixed bug
o |

I want to stop developers from accidentally pushing changes to the stable branch. How can I achieve this? I know there are ways of hooking into certain Mercurial events, but which one could reject a push if it made changes to the stable branch? And how can I detect that changes have been made in certain branches within a hook?

I'm running Windows 7 by the way.

UPDATE

Thanks to criswel for his answer - it pointed me in the right direction. Turns out the ACL extension (which comes with mercurial) solved this problem. I edited the 'hgrc' file in the main repo's '.hg' folder to look like this:

[extensions]
acl = 

[hooks]
pretxnchangegroup.acl = python:hgext.acl.hook

[acl]
sources = push

[acl.deny.branches]
stable = *

This stops anyone from making changes to the stable branch and pushing them to the main repo.


Solution

  • It sounds like what you want is the ACL extension, which should be included in your install of Mercurial.