2011-05-24 65 views
1

是否可以使用Mercurial指定未版本控制文件的初始狀態?Mercurial指定未版本控制文件的初始狀態

更具體地說,我想這工作:

[email protected] ~$ mkdir initial-state 
[email protected] ~$ cd initial-state/ 
[email protected] ~/initial-state$ hg init 
[email protected] ~/initial-state$ touch main.cpp 
[email protected] ~/initial-state$ touch config.cpp 
[email protected] ~/initial-state$ hg add  
adding config.cpp 
adding main.cpp 
[email protected] ~/initial-state$ echo "config.cpp" > .hgignore 
[email protected] ~/initial-state$ hg add 
adding .hgignore 
[email protected] ~/initial-state$ hg commit -m "initial commit" 
[email protected] ~/initial-state$ echo "#define CONFIG true" >> config.cpp 

# This is what I would like to see: 
[email protected] ~/initial-state$ hg status 
[email protected] ~/initial-state$ 

# This is what happens: 
[email protected] ~/initial-state$ hg status 
M config.cpp 
[email protected] ~/initial-state$ 
+0

爲什麼要這樣做? – 2011-05-24 19:33:17

+0

所以我可以創建默認內容的本地配置文件。 – 2011-05-24 19:34:04

+0

不,我的意思是你爲什麼不想看到他們的狀態? – 2011-05-24 19:37:17

回答

2

你想要做的加入main.cpp.hgignore之前提交的main.cpp的最初版本是什麼。原因main.cpp仍然顯示在hg status上的原因是,因爲它在第一次提交時列在.hgignore中,所以第一次提交實際上並未提交對main.cpp(初始版本)的更改。

所以,與其:

 
% hg init 
% touch main.cpp 
% hg add main.cpp 
% hg ci -m "Initial commit" 
% echo "main.cpp" >.hgignore 
% hg add .hgignore 
% hg ci -m "Update hg ignore" 
% echo "wotnot" >main.cpp 
% hg status 
# you should see nothing 

說了這麼多,把main.cpp.hgignore不會阻止未來的承諾文件。該文件可以通過執行如下操作來更改和提交:hg ci -m "commit main.cpp" main.cpp