Setting Mercurial's execute bit on Windows

后端 未结 3 1929
野性不改
野性不改 2021-02-19 20:39

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

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-19 20:53

    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

提交回复
热议问题