本文介绍了在Mercurial中,当Peter“hg clone”我,我承诺,他拉和更新,他得到我的版本,但不是当我回滚?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也就是说,在Mercurial中,如果彼得从我身上克隆出来的话,代码

放入他的e:\ code

code.txt ,它包含文本代码是7



现在,当我将它更改为时,代码是11 和hg commit,然后他可以使用hg pull和hg获取我的代码更新。现在他的版本说代码是11



但是,如果我决定更改是错误的并且hg rollback,那么我的仓库应该有 7 版本,而工作目录应该有 11 版本。



因此,当Peter执行hg pull和hg update时,他应该同步到我当前的存储库,即 7 ,但我发现情况并非如此 - 他仍然获得了 11 版本。这是为什么?他可以得到回滚代码( 7 )吗? Git的行为方式也一样吗?



更新:我认为 commit 会影响存储库的方式与 rollback 影响存储库的方式相同 - 提交和回滚都是数据库事务处理单词......现在我们说 commit 影响仓库,但是 rollback 不会?这里有什么规则?



更新2:此时,如果Mary做了一个

  hg clone c:\mycode e:\marycode 

在这一点上,她实际上获得了 7 版本。所以,玛丽得到 7 。彼得得到 11 。他们都是最新?这是什么?

解决方案

hg pull pull down new 远程存储库中的变更集 - 但它不会删除远程不存在的变更集。否则,做一次拉动就会抹去你尚未推到遥控器上的任何工作。因此,拉并没有摆脱被拖动的变更集,然后遥控器将其回滚,因为没有新的变更集可以抓取。



如果您制作了新的提交具有回滚状态,那么该提交将被取消,Peter将会看到它。



换句话说,你需要做的是首先使用 hg revert -r 检出您想要更改的早期版本,然后使用 hg commit 创建一个基于旧版本的新提交,然后让用户提交该提交。


That is, in Mercurial, if Peter cloned from me by

hg clone c:\mycode e:\code

into his e:\code

let's say there is a file code.txt and it contains the text the code is 7

Now, when I change it to the code is 11 and hg commit, then he can get my code using hg pull and hg update. Now his version says the code is 11

But if I decide the change was wrong and hg rollback, then my repository should have the 7 version, while the working directory should have the 11 version.

So when Peter does an hg pull and hg update, he should be sync'ed up to my current repository, which is the 7, but I found that it is not the case -- he still gets the 11 version. Why is that? Can he get the rolled back code (the 7)? Does Git behave the same way too?

Update: I thought commit affects the repository the same way that rollback affects the repository -- commit and rollback are both DB transaction words... and now we are saying commit affects the repository but rollback doesn't? What's the rule here?

Update 2: At this point, if Mary does an

hg clone c:\mycode e:\marycode

at this point, she actually gets the 7 version. So, Mary gets 7. Peter gets 11. And they are both "up to date"? What is this?

解决方案

hg pull pulls down new changesets from a remote repository - but it doesn't delete ones that don't exist remotely. Otherwise, doing a pull would erase any of your own work that hadn't already be pushed to the remote. Thus, pull doesn't get rid of a changeset that was pulled, and then the remote rolled it back, because there's no new changeset to grab.

If you make a new commit which has the rolled-back state, then that commit will get pulled down and Peter will see it.

In other words, what you need to do is first use hg revert -r <previous-rev> to check out an earlier version that you want to change back to, then use hg commit to create a new commit based on the older revision, and then have people pull that commit.

这篇关于在Mercurial中,当Peter“hg clone”我,我承诺,他拉和更新,他得到我的版本,但不是当我回滚?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 02:16