在 Mercurial 中合并书签

发布于 2025-01-03 01:01:26 字数 824 浏览 1 评论 0原文

昨天问了关于 Mercurial 分支的这个问题之后,我'我们决定尝试短期分支(功能)的书签,如下所示。
然而现在,当我尝试将我的书签头合并到开发修订版中时,我收到以下错误:

hg update dev-1.1
hg merge feature1
abort: nothing to merge

我做错了什么?

我的存储库的图形表示:

o  changeset:   5:fa2b19961b46
|  bookmark:    feature1
|  description:  Work on feature 1 finished.
|
| o  changeset:   4:6ea0155d4d89
| |  bookmark:    feature2
| |  description: Work on feature 2 started. 
| |
o |  changeset:   3:44e335b5426c
| |  bookmark:    feature1
|/   description: Work on feature#1 started.
|
@    changeset:    2:407b3b94624f
|    tag:          dev-1.1
|    description:  Development for release 1.1 started. 

After asking this question yesterday about branching in mercurial, I've decided to try out bookmarks for short-lived branches (features), as shown below.
However now when I am trying to merge my bookmarked heads together into the development revision, I get below error:

hg update dev-1.1
hg merge feature1
abort: nothing to merge

What am I doing wrong?

Graphical representation of my repo:

o  changeset:   5:fa2b19961b46
|  bookmark:    feature1
|  description:  Work on feature 1 finished.
|
| o  changeset:   4:6ea0155d4d89
| |  bookmark:    feature2
| |  description: Work on feature 2 started. 
| |
o |  changeset:   3:44e335b5426c
| |  bookmark:    feature1
|/   description: Work on feature#1 started.
|
@    changeset:    2:407b3b94624f
|    tag:          dev-1.1
|    description:  Development for release 1.1 started. 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

寄风 2025-01-10 01:01:27

就像它说的那样,没有什么可以合并 - 你应该使用更新:

$ hg update feature1

你只能合并历史的不同部分,这里的 dev-1.1 变更集只是 feature1< 的祖先。 /代码> 变更集。 Mercurial 2.1 在这种情况下表示

$ hg merge feature1
abort: nothing to merge
(use 'hg update' or check 'hg heads')

,我们希望这将使错误更加清晰。

如果您已为 dev-1.1 变更集添加了书签(而不是标记它),那么普通内容

$ hg update

现在(使用 Mercurial 2.1)将导致 dev 的更新 -1.1 书签。因此,如果您从

$ hg bookmarks
 * dev-1.1                   0:b1163a24728f
   feature1                  3:c84f04513651
   feature2                  2:e60dd08af282

然后更新开始:

$ hg update
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
updating bookmark dev-1.1

那么书签就会更新:

$ hg bookmarks
 * dev-1.1                   3:c84f04513651
   feature1                  3:c84f04513651
   feature2                  2:e60dd08af282

对于早期版本,您必须执行

$ hg update feature1
$ hg bookmark -f dev-1.1

以下操作 如果普通的 hg update 无法将您带到正确的变更集,例如,如果您想与 feature2 进行“合并”。


当历史没有真正分歧时使用合并的想法来自Git。在该系统中,有一个快进合并的概念,这就是我们在 Mercurial 中所说的更新

Like it says, there is nothing to merge — you should use update instead:

$ hg update feature1

You can only merge divergent parts of history, and here the dev-1.1 changeset is simply an ancestor of the feature1 changeset. Mercurial 2.1 says

$ hg merge feature1
abort: nothing to merge
(use 'hg update' or check 'hg heads')

in this case and we hope this will make the error clearer.

If you had bookmarked the dev-1.1 changeset (instead of tagging it), then a plain

$ hg update

will now (with Mercurial 2.1) result in an update of the dev-1.1 bookmark. So if you start with

$ hg bookmarks
 * dev-1.1                   0:b1163a24728f
   feature1                  3:c84f04513651
   feature2                  2:e60dd08af282

and then update:

$ hg update
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
updating bookmark dev-1.1

then the bookmark is updated:

$ hg bookmarks
 * dev-1.1                   3:c84f04513651
   feature1                  3:c84f04513651
   feature2                  2:e60dd08af282

With earlier versions, you would have to do

$ hg update feature1
$ hg bookmark -f dev-1.1

This still applies if a plain hg update doesn't take you to the right changeset, e.g., if you had wanted to "merge" with feature2 instead.


The idea of using merge when history hasn't really diverged comes from Git. In that system, there is a notion of a fast-forward merge, which is what we call an update in Mercurial.

や莫失莫忘 2025-01-10 01:01:27

如果变更集已公开,如果您想坚持将每个功能作为存储库中的合并,则可以强制 Mercurial 进行合并:

$ hg update feature1
$ hg debugsetparents dev-1.1 feature1
$ hg commit -m 'Feature 1 reviewed by me.'
$ hg bookmark -d feature1

如果变更集尚未公开,您可以将变更集折叠为一个:

$ hg update feature1
$ hg rebase --dest dev-1.1 --collapse
$ hg bookmark -d feature1

If the changesets have been made public, you can force Mercurial to do a merge if you want to insist on having each feature as a merge in the repository:

$ hg update feature1
$ hg debugsetparents dev-1.1 feature1
$ hg commit -m 'Feature 1 reviewed by me.'
$ hg bookmark -d feature1

If the changesets have not been made public, you can collapse the changesets into one:

$ hg update feature1
$ hg rebase --dest dev-1.1 --collapse
$ hg bookmark -d feature1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文