简体   繁体   中英

Mercurial merge permissions

Can you configure Mercurial permissions so only repository 1.1 can be merged into 1.0 and that other repositories (ie: 1.2, 1.3) can NOT be merged into 1.0? We were interested in adding some controls around what can be merged into what.

The Named Branches Case

You can't stop people from doing whatever they want on their local machine (that's the decentralized part), but you can refuse to accept those changes with a pretxnchangegroup hook. You'd need a hook that checks each incoming changeset to make sure that if it's a merge changeset (has two parents) that neither parent's branch violates your rules.

That's assuming you're talking about named branches. If you're using repos as branches, bookmarks as branches, or anonymous branches that becomes harder since the branch name isn't part of the changeset.

If you're using Named Branches you can use the AclExtension to make certain branches writeable by only select users -- perhaps only the release manager gets to push/merge into 1.0 once active development is done?

In the end, no restriction you put in place will replace good employee training.

My other answer addresses the named branches case, in which you have a few (not very great) options because the branch name is a part of the changeset and you can watch for changesets created initially on the 1.2 branch being merged into the 1.0 branch.

The Clones As Branches Case

If you're working with clones as branches (my preferred work mode) the "what branch was this changeset done on" information isn't available. What you could do, however, to put a pretxnchangegroup hook in the 1.0 repository that blocks the first changeset that you created in your 1.2 branch. Then if anyone tries to push 1.2 stuff into the 1.0 central(-ish) repository their push will be denied.

Here's an example of how to do that sort of hook: http://ry4an.org/unblog/post/mercurial_changeset_blacklist/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM