2010-02-06 34 views

回答

15

集(或撤消)上的文件的可執行位,然後將汞其標記爲修改。承諾。

您將需要啓用混帳風格的diff看到在比較輸出模式,但它仍然存在不顧。

+0

提供的解決方案,我沒有這與Mercurial 2.7.1相同的經驗。對我而言,更改文件上的可執行標誌不會更改該文件的狀態。 – 2014-01-15 14:28:51

+5

這並不工作在Windows上,它沒有這樣的觀念 - 見https://stackoverflow.com/questions/2702825/setting-mercurials-execute-bit-on-windows – 2014-02-13 14:49:30

0

對於Linux或Unix您可以使用chmod +x filename

對於Windows,您需要創建一個補丁文件,然後使用--bypass參數將其應用於hg import。這可以通過創建一個名爲SetFileExecutable.ps1 PowerShell腳本文件來完成,下面

param (
    [String]$comment = "+execbit", 
    [Parameter(Mandatory=$true)][string]$fileRelativePath, 
    [Parameter(Mandatory=$true)][string]$repositoryRoot 
) 

$fileRelativePath = $fileRelativePath.Replace('\', '/') 

$diff = "$comment" + [System.Environment]::NewLine + 
    [System.Environment]::NewLine + 
    "diff --git a/$fileRelativePath b/$fileRelativePath" + [System.Environment]::NewLine + 
    "old mode 100644" + [System.Environment]::NewLine + 
    "new mode 100755" 

Push-Location 
cd $repositoryRoot 
$diff | Out-File -Encoding 'utf8' $env:tmp\exebit.diff 
hg import --bypass -m "$comment" $env:tmp\exebit.diff 
Pop-Location 

文本如下執行:

.\SetFileExecutable.ps1" -comment "Marking file as executable" -fileRelativePath mvnw -repositoryRoot "c:\myrepo" 

的使用由Matt Harbison in Mercurial's Bugzilla