Sylvain
Sylvain

Reputation: 19249

How to prevent Mercurial commits/pushes of certain files?

At a point in our development process we send all *.resx files to a translator. The translator usually takes a week to send back the files. During this time no one is allowed to add, remove or update any resx file.

How can I configure mercurial to enforce that policy?

Our setup: Each dev works with a local clone of our central repository.

Nice to have:

  1. I'll turn the "policy" on and off every few weeks. So ideally, I'd like something that is easy to configure at one place and that affect all devs.

  2. I'd rather enforce that policy at the local repository level then at the central repository level because if we prevent the "push" on the central repository, it will be harder for the dev to undo the already locally committed changeset.

Thanks


UPDATE:

More info on the translation process:

Merging is not an issue here. The translator does not change the files that we sent to him. We send him a bunch of language neutral .resx (form1.resx) and returns a bunch of language specific resx (form1.FR.resx).

Why prevent adding new resx? Adding a resx occurs when we add a new UI to our application. If we do that after the translation package has been sent, the translator won't know about the new UI and we'll end up with a new UI with no translation.

Why prevent updating resx? If the dev changes a label value from "open" to "close", he has made a very important semantic change. If he does that after the translation package has been sent, we won't get the right translation back.

Upvotes: 4

Views: 1620

Answers (2)

Ivo
Ivo

Reputation: 3436

You could add *.resx to the hgignore file

Upvotes: 0

Ry4an Brase
Ry4an Brase

Reputation: 78330

You cannot stop by people from committing changes to .resx files unless you have control over their desktop machines (using a pretxncommit hook), and even then it's easily bypassed. It's much more normal to put the check on the central server at time of push using a pretxnchangegroup hook, but you're right that they'll have to fix up any changesets and re-push, which is advanced usage. In either case you'd used the AclExtension to enforce the actual restriction.

Here are two alternate ways to go about this that might work out better for you:

  1. Clone your repository at the start of the translation process, warn developers to leave .resx alone for awhile, apply the work of the translators when they're done, and then merge those changes back into the main development repository with a merge command that always gives the incoming changes priority: X . Then use a simple hg log command to find all the changes in .resx that just got overwritten and tell the developers to re-add them. Chide them at this time.

alternately

  1. Make the .resx files a Subrepository of the larger outer repository. Then turn off write access to that resx repository during the forbidden period. Developers will be able to commit in the outer repository but not the inner one, but clones will still get both exactly as they always did.

For what it's worth, everyone else handles this problem with simple merging, .resx is (XML) text, and it merges just fine.

When working with a DVCS it's not always easy to exactly mirror your svn experience, but there's usually a better option anyway.

Upvotes: 4

Related Questions