如何防止Mercurial提交/推送某些文件? [英] How to prevent Mercurial commits/pushes of certain files?

查看:67
本文介绍了如何防止Mercurial提交/推送某些文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在开发过程中的某个时刻,我们将所有* .resx文件发送到翻译器.翻译人员通常需要一周的时间才能发回文件.在此期间,不允许任何人添加,删除或更新任何resx文件.

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.

我如何配置Mercurial来执行该策略?

How can I configure mercurial to enforce that policy?

我们的设置:每个开发人员都使用我们中央存储库的本地克隆.

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

很好玩:

  1. 我将每隔几周打开和关闭政策".因此,理想情况下,我希望可以在一个地方轻松配置并且会影响所有开发人员的东西.

  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.

我宁愿在本地存储库级别然后在中央存储库级别执行该策略,因为如果我们防止在中央存储库上进行推送",则开发人员将更难撤消已经本地提交的操作变更集.

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.

谢谢

更新:

有关翻译过程的更多信息:

More info on the translation process:

合并在这里不是问题.译者不会更改我们发送给他的文件.我们向他发送一堆语言中立的.resx(form1.resx),并返回一堆语言特定的resx(form1.FR.resx).

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).

为什么阻止添加新的resx?当我们向应用程序中添加新的UI时,就会添加resx.如果在发送翻译包后执行此操作,那么翻译人员将不知道新的UI,我们将最终获得一个没有翻译的新UI.

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.

为什么阻止更新resx?如果开发人员将标签值从打开"更改为关闭",那么他将进行非常重要的语义更改.如果他在发送翻译包后这样做了,我们将无法获得正确的翻译.

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.

推荐答案

除非您能控制他们的台式机(使用pretxncommit钩子),否则您不能阻止人们将更改提交给.resx文件.它很容易被绕过.在push时使用pretxnchangegroup挂钩将检查放在中央服务器上是更正常的做法,但是您说得对,他们必须修复所有变更集并重新推送,这是正确的用法,这是正确的.无论哪种情况,您都可以使用 AclExtension 来实施实际的限制.

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. 在翻译过程开始时克隆您的存储库,警告开发人员暂时不要使用.resx,在完成后应用翻译程序的工作,然后使用<将这些更改合并回主开发存储库中.一个href ="http://mercurial.selenic.com/wiki/TipsAndTricks#Keep_.22My.22_or_.22Their.22_files_when_doing_a_merge" rel ="nofollow">合并命令,该命令始终赋予传入的更改优先级:X.然后,使用简单的hg log命令在.resx中查找刚刚被覆盖的所有更改,并告诉开发人员重新添加它们.此时责骂他们.
  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.

替代

  1. 使.resx文件成为较大外部存储库的子存储库.然后在禁止的时间段内关闭对该resx存储库的写访问.开发人员将能够在外部存储库中进行提交,但不能在内部存储库中进行提交,但是克隆仍将像往常一样完全获得两者.
  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.

对于它的价值,其他所有人都可以通过简单的合并来解决此问题,.resx是(XML)文本,并且可以很好地合并.

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

使用DVCS时,准确反映您的svn体验并不总是那么容易,但是通常总会有更好的选择.

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

这篇关于如何防止Mercurial提交/推送某些文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆