12

一部のマシンでは ext3、他のマシンでは FAT32 などの Unix ファイルシステムにチェックアウトされた Mercurial リポジトリで作業しています。

Subversion では、svn:executable プロパティを設定して、そのようなビットをサポートするプラットフォームでチェックアウトしたときにファイルを実行可能としてマークするかどうかを制御できます。SVN を実行しているプラ​​ットフォームや作業コピーを含むファイルシステムに関係なく、これを行うことができます。

Mercurial では、クローンが Unix ファイルシステム上にある場合、同じ効果を得るために chmod +x を実行できます。しかし、FAT ファイルシステム上のファイルの実行可能ビットを設定 (または削除) するにはどうすればよいでしょうか?

4

3 に答える 3

9

Mercurial は、実行ビットをファイル メタデータの一部として追跡します。Mercurial で明示的に設定する方法はありませんがchmod、UNIX で行われた変更を追跡します。Windows に追加されたファイルにはデフォルトで実行ビットが設定されますが、Windows の attrib コマンドでは設定できません。

実行hg log -p --gitすると、次のような実行ビットの変更を示すパッチ形式が表示されます。

$ 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

それらを設定するためにUNIXシステムにアクセスできない場合は、おそらくそのようなパッチを偽造することができますが、hg importそれは間違いなく最適ではありません.

于 2010-04-24T15:06:38.147 に答える
9

当分の間、ファイルシステムがサポートしていない場合、実行ビットを変更することはできません (将来サポートする予定です)。

于 2010-04-24T08:34:02.513 に答える
5

Windowsの場合、 Ry4anが言ったように、パッチファイルを作成してから適用する必要があります--bypassが、hg import. SetFileExecutable.ps1これは、以下のテキストを含むPowershell スクリプト ファイルを作成することで実行できます。

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"
}

次のように実行します。

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

Mercurial の Bugzilla で Matt Harbisonによって提供されたソリューションを使用します。

于 2016-07-18T14:35:20.240 に答える