20

我是 mercurial 的新手。我最近与 2 位同事建立了一个存储库,并且在推送我的代码时遇到了困难。[我在 Windows 中使用命令行 hg]。特别是当我推动时,我得到如下对话:

>hg commit -u petermr

>hg push
pushing to http://bitbucket.org/petermr/polyinfo/
searching for changes
abort: push creates new remote heads!
(did you forget to merge? use push -f to force)
>hg merge
abort: there is nothing to merge

>hg status

我害怕使用 push -f 提交,因为我认为这会产生多个头并给我们的团队带来问题。

当我尝试合并时,我得到一个类似的对话:

>hg merge -f
merging src/test/resources/PMR/algorithm/cmlAll.xml
 output file src/test/resources/PMR/algorithm/cmlAll.xml appears unchanged
was merge successful (yn)? y
merging src/test/resources/PMR/irregular/cmlAll.xml
 output file src/test/resources/PMR/irregular/cmlAll.xml appears unchanged
was merge successful (yn)? y
merging src/test/resources/PMR/massChange/cmlAll.xml
 output file src/test/resources/PMR/massChange/cmlAll.xml appears unchanged
was merge successful (yn)? y

由于有数百个文件,我无法为每个文件键入“y”,也找不到将它们合并在一起的方法。

更新我已经尝试了前(2)个答案,但仍然有问题:

>hg pull
pulling from http://bitbucket.org/petermr/polyinfo/
searching for changes
no changes found

>hg merge
abort: outstanding uncommitted merges

更新以响应@tonfa 我无法提交:

>hg commit
abort: unresolved merge conflicts (see hg resolve)

更新@balpha(我已将所有者的名称更改为 Foo)

>hg parent
changeset:   24:9ec904d2d5a2
tag:         tip
user:        petermr
date:        Sat Jan 09 16:40:38 2010 +0000
summary:     trying to sync

changeset:   22:360aedb72f0e
parent:      21:89c4bd671bd3
parent:      18:3cffa8ca3a2a
user:        Foo (not me)
date:        Fri Jan 08 16:15:50 2010 +0000
summary:     merged


>hg tip
changeset:   24:9ec904d2d5a2
tag:         tip
user:        petermr
date:        Sat Jan 09 16:40:38 2010 +0000
summary:     trying to sync

更新

汞头

changeset:   24:9ec904d2d5a2
tag:         tip
user:        petermr
date:        Sat Jan 09 16:40:38 2010 +0000
summary:     trying to sync

changeset:   22:360aedb72f0e
parent:      21:89c4bd671bd3
parent:      18:3cffa8ca3a2a
user:        Foo (not me)
date:        Fri Jan 08 16:15:50 2010 +0000
summary:     merged

在下面的@balpha 评论之后更新谁建议 revert 要求修订(这是一个数字吗?如果是,我怎么找到它?)

>hg revert --all
abort: uncommitted merge - please provide a specific revision

UPDATE仍然无法合并...

>hg revert --all -r tip
reverting .hgignore
reverting .hgignore~
reverting src\test\java\org\xmlcml\cml\converters\polyinfo\RegressionTest.java
reverting src\test\resources\PMR\algorithm\cmlAll.xml
reverting src\test\resources\PMR\irregular\cmlAll.xml
reverting src\test\resources\PMR\massChange\cmlAll.xml
reverting src\test\resources\PMR\massChangeOk\cmlAll.xml
reverting src\test\resources\PMR\ok\P340076.both.svg
reverting src\test\resources\PMR\ok\P340076.p.svg
reverting src\test\resources\PMR\ok\P340076.r.svg
reverting src\test\resources\PMR\ratio\cmlAll.xml

>hg status
M .hgignore
M .hgignore~
M src\test\resources\PMR\algorithm\cmlAll.xml
M src\test\resources\PMR\irregular\cmlAll.xml
M src\test\resources\PMR\massChange\cmlAll.xml
M src\test\resources\PMR\massChangeOk\cmlAll.xml
M src\test\resources\PMR\ok\P340076.both.svg
M src\test\resources\PMR\ok\P340076.p.svg
M src\test\resources\PMR\ok\P340076.r.svg
M src\test\resources\PMR\ratio\cmlAll.xml
? src\test\resources\PMR\bug\P020006work.both.svg
? src\test\resources\PMR\irregular\cmlAll.xml.resolve

>hg merge
abort: outstanding uncommitted merges

>hg commit
abort: unresolved merge conflicts (see hg resolve)

注意

hg resolve -all

提出了必须对数百个单独的问题回答“y”的原始问题,我不知道它是否会解决问题。非常感谢您的帮助!

更新@balpha 建议清洁 - 这似乎取得了进展

>hg update --clean -r tip
10 files updated, 0 files merged, 0 files removed, 0 files unresolved

>hg merge
merging src/test/resources/PMR/algorithm/cmlAll.xml
 output file src/test/resources/PMR/algorithm/cmlAll.xml appears unchanged
was merge successful (yn)? y
merging src/test/resources/PMR/irregular/cmlAll.xml
 output file src/test/resources/PMR/irregular/cmlAll.xml appears unchanged
was merge successful (yn)? y
merging src/test/resources/PMR/massChange/cmlAll.xml
 output file src/test/resources/PMR/massChange/cmlAll.xml appears unchanged
was merge successful (yn)? y
merging src/test/resources/PMR/massChangeOk/cmlAll.xml
 output file src/test/resources/PMR/massChangeOk/cmlAll.xml appears unchanged
was merge successful (yn)? y
merging src/test/resources/PMR/ok/P340076.both.svg
 output file src/test/resources/PMR/ok/P340076.both.svg appears unchanged
was merge successful (yn)? y
merging src/test/resources/PMR/ok/P340076.p.svg
 output file src/test/resources/PMR/ok/P340076.p.svg appears unchanged
was merge successful (yn)? y
merging src/test/resources/PMR/ok/P340076.r.svg
 output file src/test/resources/PMR/ok/P340076.r.svg appears unchanged
was merge successful (yn)? y
merging src/test/resources/PMR/ratio/cmlAll.xml
 output file src/test/resources/PMR/ratio/cmlAll.xml appears unchanged
was merge successful (yn)? y
2 files updated, 8 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)

>hg merge
abort: outstanding uncommitted merges

>hg merge -f
abort: outstanding uncommitted merges

>hg commit -u petermr -m "still trying to sy
nc"

>hg merge
abort: there is nothing to merge

>hg push
pushing to http://bitbucket.org/petermr/polyinfo/
searching for changes
http authorization required
realm: Bitbucket.org HTTP
user: petermr
password:
adding changesets
adding manifests
adding file changes
added 4 changesets with 298 changes to 290 files
bb/acl: petermr is allowed. accepted payload.
quota: 13.3 MB in use, 150.0 MB available (8.87% used)
4

5 回答 5

16

您本地的 repo 克隆可能不是最新的。做一个

hg pull

改变这一点。现在您在本地有两个头(您自己以前的提示和 bitbucket 存储库的提示)。现在

hg merge

合并两个头和

hg commit -m "Merged before pushing"

现在你的本地仓库只有一个头,这个头是 bitbucket 头的孩子,所以推送将不再创建远程头:

hg push

你就完成了。

于 2010-01-09T17:26:17.173 回答
5

在将代码推送到远程存储库之前,首先确保您的本地存储库是干净的并且没有未完成的合并。

然后,从远程存储库执行 hg pull。这将在您的本地存储库上创建 2 个头。

进行本地合并并提交(解决任何冲突)。

最后,推送到远程存储库。

如果将在那里创建多个头,通常不要推送到远程存储库。

于 2010-01-09T17:27:35.190 回答
4

您可能不想在本地提交合并。清理并重新开始的方法(来自https://www.mercurial-scm.org/bts/issue1533)似乎是“hg update -C”。

正如上面提到的,“hg revert -a”似乎应该工作,但似乎没有。

于 2011-03-04T17:51:40.847 回答
0

使用 TortoiseHg 代替命令行工具,它更简单并以图形方式显示存储库的状态,因此您不会对所有命令感到困惑。

于 2012-09-24T17:56:08.540 回答
0

我有一个非常相似的问题。原来,根本原因是 Mercurial 的“排除”扩展。通过暂时关闭扩展,问题得到了解决。提到“排除”扩展页面,所有者承认这是一个已知问题。

于 2013-03-05T02:19:52.667 回答