使用hg,如何在一次更改中替換目錄的內容?hg:在一次更改中替換目錄內容
更具體地說,我有一個大型C++庫的頭文件存入我的倉庫,我想將它們更新(包括添加和刪除文件)到最新版本的庫中。我希望在一次更改中做到這一點,而不是首先刪除舊版本,然後再添加新版本,這會破壞測試併產生無益的差異。
使用hg,如何在一次更改中替換目錄的內容?hg:在一次更改中替換目錄內容
更具體地說,我有一個大型C++庫的頭文件存入我的倉庫,我想將它們更新(包括添加和刪除文件)到最新版本的庫中。我希望在一次更改中做到這一點,而不是首先刪除舊版本,然後再添加新版本,這會破壞測試併產生無益的差異。
如果他們都改變,那麼,(假設平坦的目錄結構:
hg remove \path\to\directory\to\replace\*.h
copy \path\to\new\files\*.* \path\to\directory\to\replace\
hg add \path\to\directory\to\replace\*.*
hg commit -m "Library SoAndSo headers replaced"
hg push
第一行說忘就下的所有文件提交,但隨後新的在同一添加提交 - 請記住只有最後一行實際上更改了存儲庫的本地副本,並且它只在最後一行變成公共狀態
如果您確實有子目錄,那麼您可以在第一行刪除*.h
, xcopy
或資源管理器複製新的di本地結構,並在第三行刪除*.*
。
# Change to parent directory of your vendor directory
cd vendor_dir/..
rm -rf vendor_dir
# unpack/copy/checkout new vendor sources into a new vendor_dir
# Tell mercurial to figure out what changed
# Feel free to play with the similarity percentage and the (-n) do nothing switch
hg addremove --similarity 70 vendor_dir
hg commit vendor_dir
更新時間:
hg rm *
內vendor_dir
缺失的父目錄的工作點文件,如果有的話。hg rm
更改爲rm -rf
,因爲我錯誤地認爲rm後的addremove會做正確的事情。提示:它沒有。
你的意思是:hg add \ path \ to \ directory \ to \ replace \? – Taylor 2014-09-02 20:45:53
@泰勒哎呀!是的 - 將修復。 – 2014-09-02 21:01:33
好的,頭文件dir有子目錄。這是如何改變的? – Taylor 2014-09-02 21:03:26