2016-12-28 51 views
0

我是團隊的一員,我目前的任務是重組,即移動一堆文件/文件夾。如何在團隊合作環境中使用'hg mv'?

我想使用'hg mv',但是如何將其與團隊工作同步?請記住,該團隊目前正在處理那些需要移動的文件。在我推動重組後,他們能夠拉動/更新嗎?即使我移動了他們的文件,hg是否能夠合併他們的本地更改?

另一個問題是在重組被推動之前,我的結尾是'hg up'。可以處理我移動的文件傳入的修改,但尚未推送?

+0

關於我的重構副本上的'hg up'還沒有提交 - 嗯,hg能夠處理傳入的文件的修改,但我沒有推送。這很好! – shahav

+0

似乎解決[通過](http://stackoverflow.com/questions/5190913) – shahav

回答

1

讓我們製作名爲maintommine的三個存儲庫,以瞭解發生了什麼。 main是一箇中央存儲庫,您和Tom(您的同事之一)推送更改並將其用於協作。 tom是Tom的存儲庫,mine是您的存儲庫。 tommine顯然是main的克隆。

$ hg init main 
$ hg clone main tom 
$ hg clone main mine 

讓我們來玩一個文件吧。 Tom創建了一個文件並將其推送到主存儲庫。

$ cd tom 
tom$ echo 'print hello' > a.py 
tom$ hg add 
tom$ hg ci -m "Added a.py" 
tom$ hg push 
pushing to /home/main 
searching for changes 
adding changesets 
adding manifests 
adding file changes 
added 1 changesets with 1 changes to 1 files 

現在您通過拉動變化開始。

$ cd mine 
mine$ hg pull 
pulling from /home/main 
requesting all changes 
adding changesets 
adding manifests 
adding file changes 
added 1 changesets with 1 changes to 1 files 
(run 'hg update' to get a working copy) 

mine$ hg up 
1 files updated, 0 files merged, 0 files removed, 0 files unresolved 

現在你注意到湯姆不擅長命名爲他命名的文件爲a.py這是最描述。您決定將其重命名爲hello.py

mine$ hg mv a.py hello.py 
mine$ hg ci -m "Rename a.py to hello.py" 

與此同時,湯姆跑a.py,意識到引號(print hello必須print "hello")失蹤。他解決了這個問題並推動了另一次提交你決定在推動之前拉一個。

mine$ hg pull 
pulling from /home/main 
searching for changes 
adding changesets 
adding manifests 
adding file changes 
added 1 changesets with 1 changes to 1 files (+1 heads) 
(run 'hg heads' to see heads, 'hg merge' to merge) 

mine$ hg merge 
merging hello.py and a.py to hello.py 
0 files updated, 1 files merged, 0 files removed, 0 files unresolved 
(branch merge, don't forget to commit) 

mine$ hg ci -m "Merge commit" 

現在,當你看着hello.py,你會發現由湯姆修復存在,你決定來推動。

mine$ cat hello.py 
print "hello" 

mine$ hg push 
pushing to /home/main 
searching for changes 
adding changesets 
adding manifests 
adding file changes 
added 2 changesets with 2 changes to 1 files 

讓我們切換回來,看看在湯姆這邊推動後會發生什麼。湯姆在本地做了一個他沒有推的改變。改變是關於添加圓括號來打印功能。

tom$ hg pull 
pulling from /home/main 
searching for changes 
adding changesets 
adding manifests 
adding file changes 
added 2 changesets with 2 changes to 1 files (+1 heads) 
(run 'hg heads' to see heads, 'hg merge' to merge) 

tom$ hg merge 
merging a.py and hello.py to hello.py 
0 files updated, 1 files merged, 0 files removed, 0 files unresolved 
(branch merge, don't forget to commit) 

tom$ hg ci -m "Merge heads" 
tom$ hg push 
pushing to /home/main 
searching for changes 
adding changesets 
adding manifests 
adding file changes 
added 2 changesets with 2 changes to 2 files 

當您將這次拉,你的湯姆存儲庫將具有相同的狀態與文件重命名和所有更改完好無損。

mine$ hg pull 
pulling from /home/main 
searching for changes 
adding changesets 
adding manifests 
adding file changes 
added 2 changesets with 2 changes to 2 files 
(run 'hg update' to get a working copy) 

$ hg up 
$ cat hello.py 
print("hello") 

您可以看到添加括號的更改也存在。所以它非常安全的重命名文件Mercurial使用hg mv

相關問題