##// END OF EJS Templates
contrib: make editmergeps use -NoNewWindow option in Start-Process cmdlet...
Kostia Balytskyi -
r32569:4daf5c18 default
parent child Browse files
Show More
@@ -1,79 +1,79 b''
1 # A simple script for opening merge conflicts in editor
1 # A simple script for opening merge conflicts in editor
2 # A loose translation of contrib/editmerge to powershell
2 # A loose translation of contrib/editmerge to powershell
3 # Please make sure that both editmergeps.bat and editmerge.ps1 are available
3 # Please make sure that both editmergeps.bat and editmerge.ps1 are available
4 # via %PATH% and use the following Mercurial settings to enable it
4 # via %PATH% and use the following Mercurial settings to enable it
5 #
5 #
6 # [ui]
6 # [ui]
7 # editmergeps
7 # editmergeps
8 # editmergeps.args=$output
8 # editmergeps.args=$output
9 # editmergeps.check=changed
9 # editmergeps.check=changed
10 # editmergeps.premerge=keep
10 # editmergeps.premerge=keep
11
11
12 $file=$args[0]
12 $file=$args[0]
13
13
14 function Get-Lines
14 function Get-Lines
15 {
15 {
16 Select-String "^<<<<<<" $file | % {"$($_.LineNumber)"}
16 Select-String "^<<<<<<" $file | % {"$($_.LineNumber)"}
17 }
17 }
18
18
19 $ed = $Env:HGEDITOR;
19 $ed = $Env:HGEDITOR;
20 if ($ed -eq $nil)
20 if ($ed -eq $nil)
21 {
21 {
22 $ed = $Env:VISUAL;
22 $ed = $Env:VISUAL;
23 }
23 }
24 if ($ed -eq $nil)
24 if ($ed -eq $nil)
25 {
25 {
26 $ed = $Env:EDITOR;
26 $ed = $Env:EDITOR;
27 }
27 }
28 if ($ed -eq $nil)
28 if ($ed -eq $nil)
29 {
29 {
30 $ed = $(hg showconfig ui.editor);
30 $ed = $(hg showconfig ui.editor);
31 }
31 }
32 if ($ed -eq $nil)
32 if ($ed -eq $nil)
33 {
33 {
34 Write-Error "merge failed - unable to find editor"
34 Write-Error "merge failed - unable to find editor"
35 exit 1
35 exit 1
36 }
36 }
37
37
38 if (($ed -eq "vim") -or ($ed -eq "emacs") -or `
38 if (($ed -eq "vim") -or ($ed -eq "emacs") -or `
39 ($ed -eq "nano") -or ($ed -eq "notepad++"))
39 ($ed -eq "nano") -or ($ed -eq "notepad++"))
40 {
40 {
41 $lines = Get-Lines
41 $lines = Get-Lines
42 $firstline = if ($lines.Length -gt 0) { $lines[0] } else { $nil }
42 $firstline = if ($lines.Length -gt 0) { $lines[0] } else { $nil }
43 $previousline = $nil;
43 $previousline = $nil;
44
44
45
45
46 # open the editor to the first conflict until there are no more
46 # open the editor to the first conflict until there are no more
47 # or the user stops editing the file
47 # or the user stops editing the file
48 while (($firstline -ne $nil) -and ($firstline -ne $previousline))
48 while (($firstline -ne $nil) -and ($firstline -ne $previousline))
49 {
49 {
50 if ($ed -eq "notepad++")
50 if ($ed -eq "notepad++")
51 {
51 {
52 $linearg = "-n$firstline"
52 $linearg = "-n$firstline"
53 }
53 }
54 else
54 else
55 {
55 {
56 $linearg = "+$firstline"
56 $linearg = "+$firstline"
57 }
57 }
58
58
59 Start-Process -Wait $ed $linearg,$file
59 Start-Process -Wait -NoNewWindow $ed $linearg,$file
60 $previousline = $firstline
60 $previousline = $firstline
61 $lines = Get-Lines
61 $lines = Get-Lines
62 $firstline = if ($lines.Length -gt 0) { $lines[0] } else { $nil }
62 $firstline = if ($lines.Length -gt 0) { $lines[0] } else { $nil }
63 Write-Output "firstline is: $firstline, previousline is: $previousline"
63 Write-Output "firstline is: $firstline, previousline is: $previousline"
64 }
64 }
65 }
65 }
66 else
66 else
67 {
67 {
68 $ "$ed" $file
68 $ "$ed" $file
69 }
69 }
70
70
71 $conflicts=Get-Lines
71 $conflicts=Get-Lines
72 if ($conflicts.Length -ne 0)
72 if ($conflicts.Length -ne 0)
73 {
73 {
74 Write-Output "merge failed - resolve the conflicts (line $conflicts) then use 'hg resolve --mark'"
74 Write-Output "merge failed - resolve the conflicts (line $conflicts) then use 'hg resolve --mark'"
75 exit 1
75 exit 1
76 }
76 }
77
77
78 exit 0
78 exit 0
79
79
General Comments 0
You need to be logged in to leave comments. Login now