在 Mercurial 中防止升级到旧版本(标签或分支)

in Mercurial prevent to up to a older version (tag or branch)

有什么方法可以防止回到旧版本吗?

我的意思是,我想一直做 hg 前进,永远不要后退。

利用 hooks which mercurial offers and implement a hook to the update command which compares the desired version with the currently checked-out version. Fail the hook, when the desired version is older than the currently checked-out one. See the docs for the available hooks and some examples.

也就是说,这可能是对 VCS 使用的不良限制。如果它是关于在生产系统上的部署,那就更明智了;然后您不需要复制整个存储库及其历史记录,而只需将当前版本复制到部署目标。

为了我的部署目的,我只检查构建是否设置为发布构建(标记,或在 jenkins 中手动选择)或者它是否是分支的 HEAD。在这些情况下,我会在构建通过回归测试后触发部署到生产环境:https://github.com/OpenTTD/nml/blob/master/.devzone/build/jenkins_postbuild.sh