变化无常的变革冲突
我现在正在使用 SVN 的 Mercurial...使用 SVN 我从未丢失任何更改,合并非常智能。使用 Mercurial,当我提交本地更改时,我只是从主存储库中进行了拉取,它覆盖了我的本地更改。场景如下...
对于 file.php,前 250 行是相同的。在本地,我添加了 3 个函数,因为我正在处理一个特定的功能。我提交了更改,但忘记推送到 DEV。所以在 DEV 上我也添加了 3 个新功能。本地 3 个函数(尽管完全不同)被 DEV 上的 3 个函数覆盖...
我似乎无法想到发生这种情况的逻辑原因...
我使用的是 TortoiseHG,而不是命令行。
I'm now working with Mercurial from SVN.... with SVN I never lost any changes, the merging was very intelligent. With Mercurial, I just did a pull from the main repo when I've committed local changes and it overwrote my local changes. Here's the scenario...
with file.php the first 250 lines were identical. Locally I added 3 functions cause I was working a specific feature. I committed my changes and forgot to push up to DEV. So on DEV I added 3 new functions as well. The local 3 functions (despite being completely different) were overwritten by the 3 functions on DEV...
I can't seem to think of a logical reason why this is happening...
I'm using TortoiseHG, not command line.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的描述中缺少一个步骤。根据描述,DEV 从未看到过所谓丢失的功能;它不可能覆盖它们。但是,您可以从 DEV 中提取更改,获得与 DEV 相同的工作分支,而本地提交是另一片叶子。在这种情况下,您可以通过合并两个分支来恢复它们。使用
hg Heads
找出是否还有另一个未完成(未合并)的分支。关键的一步是更新,例如
hg pull -u
或hg update -c
,这将隐藏(但不会损坏)本地提交的工作。自从我看到你使用 TortoiseHg 以来进行编辑:
TortoiseHg 工作台 很好地显示了树。拉动确实会按照我的预期创建分支,而新的提示确实是我从单独的存储库中拉出的。工作台显示当前工作目录(如 1+),因此您可以看到它来自哪个分支;尝试选择其他分支并选择“与本地合并”以收集所有更改。
Mercurial 不会自动为您合并内容的原因是哲学上的而不是技术上的。 cvs/svn 工作流程有采用管理程序的分支,并且每个分支的提交都必须与中央存储库保持同步;因此所有更新都会合并。相反,Mercurial 和 git 采用的方法是分支应该很容易,您可以选择何时以及是否将每个分支加入到任何其他分支,并且为分支命名是一项单独的任务。 TortoiseHg 中的拉取对话框可以尝试使用拉取后设置更新和自动解决合并冲突来表现得更像 cvs。
Mercurial wiki 有一篇关于 Mercurial 工作流程的文章。特别是, CvsLikePractice 可能比我更好地解释了分支。
There's a step missing in your description. By the description, DEV never saw the supposedly lost functions; it can't have overwritten them. You can, however, pull changes from DEV, getting a working branch identical to DEV while your local commits are another leaf. In this case, you can get them back by doing a merge of the two branches. Use
hg heads
to find out if you have another unfinished (not merged) branch.The crucial step would be an update, such as
hg pull -u
orhg update -c
, which would hide (but not damage) the locally commited work.Edit since I saw you use TortoiseHg:
The TortoiseHg workbench shows the tree quite nicely. A pull does create branches as I expected, and the new tip was indeed the one I pulled from the separate repository. The workbench shows the current working directory (as something like 1+), so you can see which branch it came from; try selecting the other branch and choosing "Merge with local" to collect all the changes.
The reason Mercurial doesn't merge things automatically for you is philosophical rather than technical. The cvs/svn workflow has branches taking an administrative procedure and every commit into a branch has to be current with the central repository; therefore all updates do merges. Mercurial and git instead take the approach that branching should be easy, and you may choose when and if to join each branch to any other branch, and giving a name to a branch is a separate task. The pull dialog in TortoiseHg can attempt to behave more like cvs using the Post Pull settings Update and Automatically resolve merge conflicts.
The Mercurial wiki has an article on Mercurial workflows. In particular, CvsLikePractice probably explains the branching better than I.
在发现本地版本中的行丢失之前,您运行了哪个 Mercurial 命令?
你从 DEV 那里做了 hg pull 吗?
我以前从未见过 Mercurial 丢失这样的变更集,我想如果您按照您所说的那样提交了所有内容,那么这些更改至少会出现在文件历史记录中的某个位置。
What Mercurial command did you run before noticing that the lines in your local version were missing?
Did you do an hg pull from DEV?
I haven't seen Mercurial lose changesets like this before, I imagine that if you committed everything as you've said that the changes are at a minimum in the file history somewhere.