2010-01-09 97 views
18

我是mercurial的新手。我最近與2位同事建立了一個存儲庫,並且在推送我的代碼時遇到了困難。 [我在Windows中使用命令行hg]。特別是當我推我得到類似下面的對話:無法在mercurial中合併

>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 

恐怕用推-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」和我找不到合併它們放在一起的一種方式。

UPDATE我試圖第一(2)的回答,仍然有一個問題:

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

>hg merge 
abort: outstanding uncommitted merges 

UPDATE響應於@tonfa我不能承諾:

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

UPDATE @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 

UPDATE

汞柱頭

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 

UPDATE遵循以下建議誰恢復它的修改過程要求(這也是衆多@balpha評論?如果是的話我怎麼找到它?)

>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」數以百計的個人問題,我不知道它是否會解決問題。非常感謝您的幫助!

UPDATE @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) 
+0

只是提交合並的結果。 – tonfa 2010-01-09 17:47:59

+0

請發佈'hg parent'和'hg tip'的輸出 – balpha 2010-01-09 17:54:18

+0

...和'hg heads' – balpha 2010-01-09 17:59:46

回答

15

您當地的回購協議的副本可能是沒有及時更新。做一個

hg pull 

改變這一點。現在你在本地有兩個頭(你自己以前的技巧和bitbucket回購的技巧)。現在

hg merge 

合併兩個頭和

hg commit -m "Merged before pushing" 

現在你的本地倉庫只有一個頭,這個頭是到位桶頭的孩子,所以按鍵將創建遠程頭:

hg push 

你就完成了。

+0

這似乎不允許我合併 - 請參閱UPDATE – 2010-01-09 17:47:06

+1

+1繼續幫助交互 – 2010-01-09 18:08:48

+1

接受的答案,但請參閱有關問題的討論詳細信息 – 2010-01-09 19:05:47

5

在將代碼推送到遠程存儲庫之前,首先確保您的本地回購是乾淨的並且沒有未完成的合併。

然後,從遠程存儲庫執行hg pull操作。這將在您的本地資源庫中創建2個頭。

做一個本地合併,並提交(解決任何衝突)。

最後,推送到遠程存儲庫。

如果在那裏創建多個頭,通常不要推送到遠程存儲庫。

+0

+1因爲「回購必須是乾淨的「部分是在這種情況下至關重要的事情 – balpha 2010-01-09 20:32:25

+0

@Tarydon:」首先確保您的本地回購清潔並沒有出色的合併。「你能解釋一下怎麼做嗎? – MikeSchinkel 2011-11-13 02:28:27

4

您可能不想在本地提交合並。清理並重新開始的方式(從https://www.mercurial-scm.org/bts/issue1533)似乎是「hg update -C」。

正如上文所提到的,似乎「hg revert -a」應該工作,但似乎並不如此。

+1

我確實在原始問題的頂部描述了問題,並發現將所有已更改的文件複製出來,'hg update -C',然後複製回給我的更改。 – dukedave 2011-11-22 15:55:27

0

使用TortoiseHg代替命令行工具,它更簡單並以圖形方式顯示存儲庫的狀態,因此您不會與所有命令混淆。

0

我有一個非常類似的問題。發現根本原因是Mercurial的「排除」擴展。通過臨時關閉分機,問題得到解決。 參考「排除」擴展頁面,所有者承認這是一個已知問題。