【问题标题】:Temporarily switch working copy to previous revision in Mercurial?临时将工作副本切换到 Mercurial 中的先前版本?
【发布时间】:2019-04-01 23:37:15
【问题描述】:

这与Temporarily switch working copy to a specific Git commit 基本上是相同的问题,但对于 Mercurial

假设修订版 500 是我在 Mercurial 中提交的最后一个修订版。我又做了一些工作,并意识到在早期的修订中出了点问题。所以,我已经“git stashed”,也就是说,hg shelved 我当前的更改,所以我在一个干净的修订版 500。

现在我要做的是检查修订版499,重建软件,看看它是否仍然有错误;如果是,则检查修订版 498,重建软件,看看是否仍有错误;如果是,修订497,重建软件,看看它是否仍然有错误;等等,直到我弄清楚哪个版本引入了错误。

完成后,我想回到修订版 500,unshelve 我以前的工作,添加修复,然后进行新的提交(修订版 501)。这意味着当我回到历史时,我不想重置任何东西,也不想从那里上演任何东西。

在 git 中,我可以通过 git checkout HASH 回到历史,一旦完成,git checkout master 就可以回到提示。 我应该在 Mercurial 中使用哪些命令?

【问题讨论】:

标签: mercurial


【解决方案1】:

您可以使用 hg update 转到旧版本:

hg update 499  # The short id number or the full hash

或者,如果您想在不需要知道 id 的情况下进入父变更集,您可以使用 mercurial revset:

hg update .~1

一旦您确定了您的问题,您就可以:

hg update tip

并取消搁置您的更改,添加您的修复并提交。

我建议您阅读 Mercurial:权威指南。您的问题非常基本/入门级 mercurial 用法。

编辑:Mercurial:权威指南的链接是:

http://hgbook.red-bean.com/read/

或本书的 1.9 版本:

https://book.mercurial-scm.org/read/index.html

【讨论】:

    猜你喜欢
    • 2012-05-01
    • 2012-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-03
    相关资源
    最近更新 更多