我試圖使用mercurial文件集來添加目錄樹中的所有文件,不包括非常大的文件和任何二進制文件。從善變文檔惡癖,這個命令應該這樣做:添加文件時爲什麼不能使用mercurial文件集?
hg init
hg add 'set: size("<1M") and not binary()'
然而,這返回0的狀態碼,並沒有添加任何東西到我的新的,空的回購協議。我試過了'set:not binary()',那也不管用。 令人沮喪的是,雖然我可以谷歌的mercurial文件集,並找到很多的例子,我找不到任何東西,以幫助解決它不工作時! 我沒有.hgignore文件,它是一個新鮮的空回購。 Mercurial 4.2.2。 我正在測試的目錄中有幾個人工創建的文件用於測試。在我的真實使用案例中,我從客戶端繼承了多吉字節的各種源代碼和二進制文件,並且我希望在我開始修復它們的問題之前將所有源代碼轉換爲mercurial,因此需要排除二進制文件和大型文件,否則嗆mercurial。
這裏是我的小測試腳本:
#!/bin/sh -ex
dd if=/dev/urandom of=binary_1k bs=1 count=1024
dd if=/dev/urandom of=binary_2M bs=1 count=2097152
echo "This. Is, a SMALL text file." > text_small
hexdump binary_1k > text_1k
hexdump binary_2M > text_2M
ls -lh
file binary_1k
file binary_2M
file text_1k
file text_2M
hg init
hg add 'set: size("<1M") and not binary()'
hg status -a
hg add 'set: not binary()'
hg status -a
hg add 'set: size("<1M")'
hg status -a
在本月底,各status命令報告在回購沒有文件,並添加命令報告沒有錯誤。