debugcommands: print out the editor that was searched for (post shlexsplit)
A user was in #mercurial and had the following settings in their hgrc:
[ui]
editor = C:\home\npp\notepad++.exe -multiInst -nosession
After shlexsplit, the first argument was mangled into C:homenppnotepad++.exe,
which was quite unlikely to exist. It took many back-and-forths to identify
that adding " characters around the exe would fix the issue; we were thinking
that it's because something was incorrectly *not* splitting and adding/moving
the " characters fixed the split boundaries, but when testing afterward it
appears that it's just mangled.
I considered adding an informational if pycompat.iswindows and \ in the string
about this issue, but was worried that might have too many false positives and
did not do so at this time.
Differential Revision: https://phab.mercurial-scm.org/D1808
from __future__ import (
absolute_import,
print_function,
)
import argparse
import os
ap = argparse.ArgumentParser()
ap.add_argument('path', nargs='+')
opts = ap.parse_args()
def gather():
for p in opts.path:
if not os.path.exists(p):
return
if os.path.isdir(p):
yield p + os.path.sep
for dirpath, dirs, files in os.walk(p):
for d in dirs:
yield os.path.join(dirpath, d) + os.path.sep
for f in files:
yield os.path.join(dirpath, f)
else:
yield p
print('\n'.join(sorted(gather(), key=lambda x: x.replace(os.path.sep, '/'))))