I work on a Mercurial repository that is checked out onto an Unix filesystem such as ext3 on some machines, and FAT32 on others.
In Subversion, I can set the svn:executa
For Windows you need to create a patch file and then apply it, like Ry4an has said, but with the --bypass
argument to hg import
. This could be done by creating a Powershell script file called SetFileExecutable.ps1
with the text below inside it
param (
[String]$comment = "+execbit",
[Parameter(Mandatory=$true)][string]$filePathRelativeTo,
[Parameter(Mandatory=$true)][string]$repositoryRoot
)
if( Test-Path -Path "$($repositoryRoot)\.hg" -PathType Container )
{
if( Test-Path -Path "$($repositoryRoot)\$($filePathRelativeTo)" -PathType Leaf )
{
$filePathRelativeTo = $filePathRelativeTo.Replace( '\', '/' )
$diff = "$comment" + [System.Environment]::NewLine +
[System.Environment]::NewLine +
"diff --git a/$filePathRelativeTo b/$filePathRelativeTo" + [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
}
else
{
Write-Host "filePathRelativeTo must the location of a file relative to repositoryRoot"
}
}
else
{
Write-Host "repositoryRoot must be the location of the .hg folder"
}
execute it as follows:
.\SetFileExecutable.ps1" -comment "Marking file as executable" -filePathRelativeTo mvnw -repositoryRoot "c:\myrepo"
The uses the solution provided by Matt Harbison in Mercurial's Bugzilla
Mercurial tracks the execute bit as part of the file metdata. There's no way to explictly set it in mercurial, but it tracks changes made by chmod
on unix. Files added on windows will have the execute bit set by default, but the windows attrib command doesn't let you set them.
If you do a hg log -p --git
you'll see the patch format that shows the altering of the execute bit, which looks like this:
$ hg log --git -p
changeset: 1:0d9a70aadc0a
tag: tip
user: Ry4an Brase <ry4an-hg@ry4an.org>
date: Sat Apr 24 10:05:23 2010 -0500
summary: added execute
diff --git a/that b/that
old mode 100644
new mode 100755
changeset: 0:06e25cb66089
user: Ry4an Brase <ry4an-hg@ry4an.org>
date: Sat Apr 24 10:05:09 2010 -0500
summary: added no execute
diff --git a/that b/that
new file mode 100644
--- /dev/null
+++ b/that
@@ -0,0 +1,1 @@
+this
If you're not able to get on to a unix system to set them, you could probably fake up a patch like that and hg import
it, but that's definitely sub optimal.
For the time being you cannot change the execute bit if the filesystem doesn't support it (I have plan to support it in the future).