Submitter | Kostia Balytskyi |
---|---|
Date | May 18, 2017, 11:06 p.m. |
Message ID | <f715f6839ba2b9319333.1495148768@devvm1416.lla2.facebook.com> |
Download | mbox | patch |
Permalink | /patch/20701/ |
State | Accepted |
Headers | show |
Comments
On Thu, May 18, 2017 at 04:06:08PM -0700, Kostia Balytskyi wrote: > # HG changeset patch > # User Kostia Balytskyi <ikostia@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@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
> -----Original Message----- > From: Augie Fackler [mailto:raf@durin42.com] > Sent: Friday, 19 May, 2017 14:43 > To: Kostia Balytskyi <ikostia@fb.com> > Cc: mercurial-devel@mercurial-scm.org > Subject: Re: [PATCH 2 of 2 contrib] contrib: make editmergeps able to work > with notepad++ > > On Thu, May 18, 2017 at 04:06:08PM -0700, Kostia Balytskyi wrote: > > # HG changeset patch > > # User Kostia Balytskyi <ikostia@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.) Me neither :P But this patch makes it so every editor will be invoked with -Wait. It seems not needed for non-Windows-UI apps (like cmd vim), but it also does not seem to hurt. > > 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@mercurial-scm.org > > https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial- > 2Dscm.org_mailman_listinfo_mercurial- > 2Ddevel&d=DwIBAg&c=5VD0RTtNlTh3ycd41b3MUw&r=Pp- > gQYFgs4tKlSFPF5kfCw&m=1ucFRbTnUDTCrF1Tgq0PGnPiICsGO- > GS0om9POdCP7U&s=_qFYXF81hHuuc3goCvrtHMakJ191DgZrVEkFFcOK9oM& > e=
> On May 19, 2017, at 15:38, Kostia Balytskyi <ikostia@fb.com> wrote: > > > >> -----Original Message----- >> From: Augie Fackler [mailto:raf@durin42.com] >> Sent: Friday, 19 May, 2017 14:43 >> To: Kostia Balytskyi <ikostia@fb.com> >> Cc: mercurial-devel@mercurial-scm.org >> Subject: Re: [PATCH 2 of 2 contrib] contrib: make editmergeps able to work >> with notepad++ >> >> On Thu, May 18, 2017 at 04:06:08PM -0700, Kostia Balytskyi wrote: >>> # HG changeset patch >>> # User Kostia Balytskyi <ikostia@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.) > Me neither :P > But this patch makes it so every editor will be invoked with -Wait. Ah. Could this be two patches then? one that does the -Wait and another that adds the support for notepad++'s linearg business? I think that's what confused me. > It seems not needed for non-Windows-UI apps (like cmd vim), but it also does not seem to hurt. > >> >> 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@mercurial-scm.org >>> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial- >> 2Dscm.org_mailman_listinfo_mercurial- >> 2Ddevel&d=DwIBAg&c=5VD0RTtNlTh3ycd41b3MUw&r=Pp- >> gQYFgs4tKlSFPF5kfCw&m=1ucFRbTnUDTCrF1Tgq0PGnPiICsGO- >> GS0om9POdCP7U&s=_qFYXF81hHuuc3goCvrtHMakJ191DgZrVEkFFcOK9oM& >> e=
Patch
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 }