4

我使用 Mercurial,但我遇到了一个奇怪的问题,我的历史非常悠久,Mercurial 的本地修订版现在有 5 个字符。在 Mercurial 中,您可以执行“hg up”,它可以在本地修订或哈希变更集之间进行选择(我不知道它用来在彼此之间进行选择的策略),在我的情况下,本地修订与 5 个第一个字符一致另一个哈希变更集。例如:

我想更新到本地版本:80145 如果我执行:

“hg 向上 80145”

Mercurial 不会更新到我想要的版本,它会更新到旧版本,因为它的哈希变更集是:

801454d1cd5e

那么,有谁知道是否有办法指定要更新到哪种类型的修订?本地修订或哈希变更集。

谢谢大家!

====

问题解决了。经过一番调查,我意识到 Mercurial 总是更新到本地版本(如果存在),否则更新到哈希变更集。在我的情况下,本地版本不存在,所以它正在更新到哈希变更集

4

1 回答 1

2

Sounds like you found your own answer (and should enter it as an answer instead of a comment and then select it -- that's not just allowed but encouraged around here), but for reference here's where that information lived:

$ hg help revisions
Specifying Single Revisions

Mercurial supports several ways to specify individual revisions.

A plain integer is treated as a revision number. Negative integers are
treated as sequential offsets from the tip, with -1 denoting the tip, -2
denoting the revision prior to the tip, and so forth.

A 40-digit hexadecimal string is treated as a unique revision identifier.

A hexadecimal string less than 40 characters long is treated as a unique
revision identifier and is referred to as a short-form identifier. A
short-form identifier is only valid if it is the prefix of exactly one
full-length identifier.

Any other string is treated as a bookmark, tag, or branch name. A bookmark
is a movable pointer to a revision. A tag is a permanent name associated
with a revision. A branch name denotes the tipmost revision of that
branch. Bookmark, tag, and branch names must not contain the ":"
character.

The reserved name "tip" always identifies the most recent revision.

The reserved name "null" indicates the null revision. This is the revision
of an empty repository, and the parent of revision 0.

The reserved name "." indicates the working directory parent. If no
working directory is checked out, it is equivalent to null. If an
uncommitted merge is in progress, "." is the revision of the first parent.

So as you found the first interpretation was as a revision number and when that didn't match anything it was tried as the prefix of a revision id. In theory this could happen with even the number 1 if your only changeset was revision 0 and its hash started with 1.

于 2012-09-17T02:41:26.243 回答