2010-02-06 45 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