Submitter | phabricator |
---|---|
Date | Jan. 5, 2018, 12:04 a.m. |
Message ID | <differential-rev-PHID-DREV-3plearrtyxfprj2kqvzn-req@phab.mercurial-scm.org> |
Download | mbox | patch |
Permalink | /patch/26543/ |
State | Superseded |
Headers | show |
Comments
krbullock requested changes to this revision. krbullock added inline comments. This revision now requires changes to proceed. INLINE COMMENTS > debugcommands.py:1212 > fm.write('editor', _("checking commit editor... (%s)\n"), editor) > - cmdpath = util.findexe(pycompat.shlexsplit(editor)[0]) > + editorbin = pycompat.shlexsplit(editor)[0] > + cmdpath = util.findexe(editorbin) In this patch, we end up printing something potentially different in the "checking" line than in the "can't find editor" line. That seems wrong. I think I'd rather we do the shlexsplit before writing the "checking commit editor..." message and print the fully-interpreted path there. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D1808 To: spectral, #hg-reviewers, krbullock Cc: krbullock, mercurial-devel
spectral added inline comments. INLINE COMMENTS > krbullock wrote in debugcommands.py:1212 > In this patch, we end up printing something potentially different in the "checking" line than in the "can't find editor" line. That seems wrong. I think I'd rather we do the shlexsplit before writing the "checking commit editor..." message and print the fully-interpreted path there. I'm not sure I agree, but I'm not sure I disagree either :) Anything using this output (it shouldn't afaik, but the user report in #mercurial said that this broke Eclipse, maybe it was only looking at debuginstall to see if there were problems and not actually parsing these values...?) might end up with incorrect results. - If we limit both of them to [0], it will end up with just the executable and miss the flags. Maybe this is fine? I don't know what Eclipse is doing with this command, basically, but I don't think we have BC guarantees on debug* commands. - If either or both of them are not limited to just [0], then they have to be output as something like `"c:\foo\bar.exe" "-arg1" "-arg2"` to show where the actual word boundaries are; we can't do something like: `' '.join(shlexed_editor)` We have to output it like that to avoid a similar problem, where instead of: [ui] editor = c:\foo\bar.exe -arg1 -arg2 the user wrote: [ui] editor = "c:\foo\bar.exe -arg1 -arg2" (Currently, that problem is slightly more obvious, since the output is `checking commit editor... ("c:\foo\bar.exe -arg1 -arg2")`). Basically... if we're ok with the rather mild BC break, I think it's probably fine to list only the editor, post-shlexsplit. I don't know what the guarantees are here. Anticipating that we're going to be OK with the output difference, since I can't see how things can actually correctly rely on the non-shlexsplit, non-findexe'd value we emit here (and thus have to assume that either nothing does, or they're already broken), I've made the change. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D1808 To: spectral, #hg-reviewers, krbullock Cc: krbullock, mercurial-devel
spectral marked an inline comment as done. spectral added a comment. Sorry, I forgot about this, can you take another look? I believe I addressed your most recent comment. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D1808 To: spectral, #hg-reviewers, krbullock Cc: krbullock, mercurial-devel
krbullock accepted this revision as: krbullock. krbullock added a comment. This LGTM now. I think the executable as interpreted by shlex, but without the added flags, gives enough signal for the user to figure out what might be wrong without confusing things. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D1808 To: spectral, #hg-reviewers, krbullock Cc: krbullock, mercurial-devel
durin42 added a comment. This looks good to me - @krbullock should I queue it? REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D1808 To: spectral, #hg-reviewers, krbullock Cc: durin42, krbullock, mercurial-devel
krbullock added a comment. @durin42 Go for it REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D1808 To: spectral, #hg-reviewers, krbullock Cc: durin42, krbullock, mercurial-devel
Patch
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py --- a/mercurial/debugcommands.py +++ b/mercurial/debugcommands.py @@ -1209,15 +1209,16 @@ editor = ui.geteditor() editor = util.expandpath(editor) fm.write('editor', _("checking commit editor... (%s)\n"), editor) - cmdpath = util.findexe(pycompat.shlexsplit(editor)[0]) + editorbin = pycompat.shlexsplit(editor)[0] + cmdpath = util.findexe(editorbin) fm.condwrite(not cmdpath and editor == 'vi', 'vinotfound', _(" No commit editor set and can't find %s in PATH\n" " (specify a commit editor in your configuration" - " file)\n"), not cmdpath and editor == 'vi' and editor) + " file)\n"), editorbin) fm.condwrite(not cmdpath and editor != 'vi', 'editornotfound', _(" Can't find editor '%s' in PATH\n" " (specify a commit editor in your configuration" - " file)\n"), not cmdpath and editor) + " file)\n"), editorbin) if not cmdpath and editor != 'vi': problems += 1