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

Kostia Balytskyi ikostia at fb.com
Thu May 18 19:06:08 EDT 2017


# 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++

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 }


More information about the Mercurial-devel mailing list