sapling/eden/hg-server/contrib/editmergeps.ps1
Durham Goode 98d9269874 server: copy hg to a new hg-server directory
Summary:
Create a fork of the Mercurial code that we can use to build server
rpms. The hg servers will continue to exist for a few more months while we move
the darkstorm and ediscovery use cases off them. In the mean time, we want to
start making breaking changes to the client, so let's create a stable copy of
the hg code to produce rpms for the hg servers.

The fork is based off c7770c78d, the latest hg release.

This copies the files as is, then adds some minor tweaks to get it to build:
- Disables some lint checks that appear to be bypassed by path
- sed replace eden/scm with eden/hg-server
- Removed a dependency on scm/telemetry from the edenfs-client tests since
  scm/telemetry pulls in the original eden/scm/lib/configparser which conflicts
  with the hg-server conflict parser.

allow-large-files

Reviewed By: quark-zju

Differential Revision: D27632557

fbshipit-source-id: b2f442f4ec000ea08e4d62de068750832198e1f4
2021-04-09 10:09:06 -07:00

105 lines
2.4 KiB
PowerShell

# A simple script for opening merge conflicts in editor
# A loose translation of contrib/editmerge to powershell
# Please make sure that both editmergeps.bat and editmerge.ps1 are available
# via %PATH% and use the following Mercurial settings to enable it
#
# [ui]
# editmergeps
# editmergeps.args=$output
# editmergeps.check=changed
# editmergeps.premerge=keep
$file=$args[0]
function Get-Lines
{
Select-String "^<<<<<<" $file | Select-Object -ExpandProperty 'LineNumber'
}
$ed = $Env:HGEDITOR;
if ($ed -eq $nil)
{
$ed = $Env:VISUAL;
}
if ($ed -eq $nil)
{
$ed = $Env:EDITOR;
}
if ($ed -eq $nil)
{
$ed = $(hg showconfig ui.editor);
}
if ($ed -eq $nil)
{
Write-Error "merge failed - unable to find editor"
exit 1
}
# if we have an editor with a full path we need to be careful of quotes
$full_path = $ed -match "^\`"(.+)\`"(.*)$"
if ($full_path)
{
$process = $Matches[1]
$process_args = $Matches[2]
}
else
{
$process = ($ed -split (" ", 2))[0]
$process_args = $ed -split (" ", 2) | select -skip 1
}
if (($ed -eq "vim") -or ($ed -eq "emacs") -or `
($ed -eq "nano") -or ($ed -eq "notepad++") -or `
($process -eq "subl"))
{
$lines = Get-Lines
$firstline = if ($lines.Length -gt 0) { $lines[0] } else { $nil }
$previousline = $nil;
# open the editor to the first conflict until there are no more
# or the user stops editing the file
while (($firstline -ne $nil) -and ($firstline -ne $previousline))
{
if ($process -eq "subl")
{
$line_arg = ":$firstline"
Start-Process -Wait -NoNewWindow $process -ArgumentList "$process_args $file$line_arg"
}
elseif ($ed -eq "notepad++")
{
$line_arg = "-n$firstline"
Start-Process -Wait -NoNewWindow $ed $line_arg,$file
}
else
{
$line_arg = "+$firstline"
Start-Process -Wait -NoNewWindow $ed $line_arg,$file
}
$previousline = $firstline
$lines = Get-Lines
$firstline = if ($lines.Length -gt 0) { $lines[0] } else { $nil }
}
}
else
{
# powershell assumes that start means Start-Process but it probably doesn't
if ($process -ne 'START')
{
Start-Process -Wait -NoNewWindow $process -ArgumentList "$process_args $file"
}
else
{
cmd /c ''$ed $file''
}
}
$conflicts = Get-Lines
if ($conflicts.Length -ne 0)
{
Write-Output "merge failed - resolve the conflicts (line $conflicts) then use 'hg resolve --mark'"
exit 1
}
exit 0