我如何始终使用“遥控器”? Mercurial 中文件的版本?
Mercurial 新手,我正在开发一个使用 Sqlite 作为数据库的 Django 项目。我开发模板和当我的同事处理后端代码时,我负责 UI 工作。我们都将更改推送到 Bitbucket。
他是唯一真正修改模型以及相应的 SQLite 文件的人,但是仅仅凭借我测试应用程序,文件也发生了变化。在完成测试后和推送之前,我总是通过执行“hg revert database.sqlite”来删除更改。
有没有一种简单的方法让我始终坚持使用他的 SQLite 文件版本,这样每次尝试同步时就不会出现合并问题?有点像“如果存在冲突,请始终使用文件的远程版本”的异常。我确实在某处的提示中看到了类似的内容,但我再也找不到它了。
Mercurial newbie here, I'm working on a Django project that uses Sqlite as the database. I develop templates & UI stuff while my colleague works on the back-end code. We both push changes to Bitbucket.
He is the only one who actually modifies the models and correspondingly, the SQLite file, however just by virtue of my testing the app, the file changes as well. I always drop my changes by doing an 'hg revert database.sqlite' after I've finished testing and before I push.
Is there a simple way for me to always stick with his version of the SQLite file so that we don't have merge issues every time we try and sync? Sort-of like an exception that says 'if there is a conflict, always use the remote version of the file'. I did see something like this in a tip somewhere, but I can't for the life of me find it again.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我同意 Matthew 的评论,即最好的解决方案是不跟踪此文件。
然而,您要求 Mercurial 始终使用远程版本的想法实际上并不遥远......:-) 您可以通过 为此文件配置一个合并工具,告诉 Mercurial 在所有合并中使用其他(远程)版本:
这应该确保您始终放弃对
database.sqlite 的更改
当你合并时。这可以让你做我刚刚有另一个想法 - 使用预合并挂钩来恢复文件:
这几乎相当于使用上面的
internal:other
合并工具,但你可能会发现它从概念上讲更简单,因为它模拟了您已经在做的事情。I agree with the comment by Matthew that the best solution is to not track this file.
However, your idea of asking Mercurial to always use the remote version is actually not that far out... :-) You do this by configuring a merge tool for this file where you tell Mercurial to use the other (remote) version in all merges:
That should make sure that you will always discard your changes to
database.sqlite
when you merge. This lets you doI just got another idea -- use a pre-merge hook to revert the file:
That is pretty much equivalent to using the
internal:other
merge tool from above, but you may find it conceptually simpler since it models what you are already doing.只要您在 shell 上工作,就有多种方法可以在提交之前执行
hg revert database.sqlite
。with
bash
:(我知道这有点便宜,但这就是我喜欢使用 shell 的原因)
As long as you work on a shell, there are numerous ways on having
hg revert database.sqlite
executed before you commit.with
bash
:(it's a bit cheap, I know, but thats why I like working with a shell)