2012-07-29 32 views
1

在致力於存儲庫我有水銀定義掛鉤:善變:包括預提交變更後的文件

[hooks] 
precommit.exportDB=exportDB.bat 

這將創建/從我的數據庫,應包含在提交更新一個SQL轉儲。 但是:雖然這個工作,Sql被標記爲新的,但不是現在提交的變更集的一部分。 我該如何自動包含它,以便它進入一組更改後的文件?

希望這是有道理...

THX 萊因哈德

回答

6

這聽起來會很瘋狂,但你可以在兩個步驟來做到。首先將你的precommit鉤子改爲pre-commit掛鉤 - 都存在,它們是不同的。沒有破折號提交已經開始,並已獲得一些鎖。使用破折號在提交開始之前發生,您仍然可以使用新文件hg add

在UNIX一樣,總的變化將是:

[hooks] 
pre-commit.exportDB=exportDB.sh && hg add resulting.sql 

大概有在Windows類似的東西,或者你可以讓hg add批處理文件的最後一行。

P.S.不要提交生成的文件。 :)

更新:

我只是測試這和它的作品,我建議:

[email protected]:~$ hg init reinhard 
[email protected]:~$ cd reinhard/ 
[email protected]:~/reinhard$ vi .hg/hgrc 
[email protected]:~/reinhard$ cat .hg/hgrc 
[hooks] 
pre-commit = hg add otherfile 
[email protected]:~/reinhard$ echo text > afile 
[email protected]:~/reinhard$ echo more > otherfile 
[email protected]:~/reinhard$ hg add afile 
[email protected]:~/reinhard$ hg status 
A afile 
? otherfile 
[email protected]:~/reinhard$ hg commit -m 'message' 
[email protected]:~/reinhard$ hg status --all 
C afile 
C otherfile 

注意,只有在提交前「å文件」,並將「otherfile」是未知的,並提交後兩個文件都是'C'(意思是「乾淨」 - 它們已被添加並提交)。

+0

thx用於預提交的提示。我還在'提交'hg add newfile.sql'結束我的腳本,但這隻會觸發另一個連續的提交,所以它不在裏面第一個更改集... – reinhard 2012-07-30 11:19:38

+0

是的,這是有效的 - 但我試圖在Windows上使用TortoiseHG進行一鍵升級updateSQLdump-and-commitChanges。這是因爲新添加的文件沒有進入變更集而導致問題,可能是因爲在創建新文件之前單擊提交文件列表已經存在。再次感謝您的時間和精力! – reinhard 2012-07-31 21:19:08