[PATCH 2 of 2 contrib] contrib: make editmergeps able to work with notepad++

Augie Fackler raf at durin42.com
Fri May 19 17:43:08 EDT 2017


On Thu, May 18, 2017 at 04:06:08PM -0700, Kostia Balytskyi wrote:
> # HG changeset patch
> # User Kostia Balytskyi <ikostia at fb.com>
> # Date 1495148281 25200
> #      Thu May 18 15:58:01 2017 -0700
> # Node ID f715f6839ba2b93193334145e677d13a0f99cf89
> # Parent  2412345e35cc0b17c98e050a480cb4b4f03bd5bb
> contrib: make editmergeps able to work with notepad++

Huh. Don't you need the -Wait for any $EDITOR? (Forgive me, I don't
know a darn thing about powershell.)

I've taken patch 1 since it seems totally reasonable.

>
> This patch teaches editmergeps to work with Notepad++ editor. Tricky part
> is to use Start-Process -Wait to make hg to wait for editor UI to close.
>
> diff --git a/contrib/editmergeps.ps1 b/contrib/editmergeps.ps1
> --- a/contrib/editmergeps.ps1
> +++ b/contrib/editmergeps.ps1
> @@ -35,7 +35,8 @@ if ($ed -eq $nil)
>    exit 1
>  }
>
> -if (($ed -eq "vim") -or ($ed -eq "emacs") -or ($ed -eq "nano"))
> +if (($ed -eq "vim") -or ($ed -eq "emacs") -or `
> +    ($ed -eq "nano") -or ($ed -eq "notepad++"))
>  {
>    $lines = Get-Lines
>    $firstline = if ($lines.Length -gt 0) { $lines[0] } else { $nil }
> @@ -46,7 +47,16 @@ if (($ed -eq "vim") -or ($ed -eq "emacs"
>    # or the user stops editing the file
>    while (($firstline -ne $nil) -and ($firstline -ne $previousline))
>    {
> -    & "$ed" "+$firstline" "$file"
> +    if ($ed -eq "notepad++")
> +    {
> +        $linearg = "-n$firstline"
> +    }
> +    else
> +    {
> +        $linearg = "+$firstline"
> +    }
> +
> +    Start-Process -Wait $ed $linearg,$file
>      $previousline = $firstline
>      $lines = Get-Lines
>      $firstline = if ($lines.Length -gt 0) { $lines[0] } else { $nil }
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list