[PATCH 1 of 3] ui: introduce util.system() wrapper to make sure ui.fout is used

Yuya Nishihara yuya at tcha.org
Tue Nov 11 07:33:00 CST 2014


On Mon, 10 Nov 2014 11:27:30 -0500, Augie Fackler wrote:
> On Mon, Nov 10, 2014 at 10:57:50PM +0900, Yuya Nishihara wrote:
> > On Sat, 08 Nov 2014 15:24:29 +0000, Pierre-Yves David wrote:
> > > On 11/08/2014 02:51 PM, Yuya Nishihara wrote:
> > > > On Sat, 08 Nov 2014 10:27:47 +0000, Pierre-Yves David wrote:
> > > >> On 11/08/2014 05:42 AM, Yuya Nishihara wrote:
> > > >>> # HG changeset patch
> > > >>> # User Yuya Nishihara <yuya at tcha.org>
> > > >>> # Date 1415419062 -32400
> > > >>> #      Sat Nov 08 12:57:42 2014 +0900
> > > >>> # Node ID d83746a91dc410f60b45916c2e55dadde4238b42
> > > >>> # Parent  2d54aa5397cdb1c697673ba10b7618d5ac25c69e
> > > >>> ui: introduce util.system() wrapper to make sure ui.fout is used
> > > >>
> > > >> The idea looks good, but can I get you to add some docstring the new
> > > >> method so that people understand its purpose?
> > > >
> > > > will do.
> > > >
> > > >> As far as I understand the lack of it makes thg command server usage to
> > > >> break in multiple occasion. Should this be target on stable?
> > > >
> > > > Not for stable. This is just a sugar for util.system(..., out=ui.fout).
> > > >
> > > > http://markmail.org/message/fwltwdugndmsb3g7
> > > >
> > > >> Finally, Do we have a plan to force people to use ui.system instead of
> > > >> util.system?
> > > >
> > > > No idea. Should we make "out" be a required parameter as well?
> > >
> > > How many case is there where util.system should be used over ui.system ?
> >
> > All util.system() in Mercurial can be replaced by ui.system().
> >
> > Possible use case of util.system() is
> >
> >     buf = StringIO()  # or temporary file
> >     util.system(..., out=buf)
> 
> Does anyone actually do this?

I found it in rupdate extension, but it seems rupdate was dead.

% grep util.system hg*/**/*.py
hgcr-gui/hgcr-gui-gtk.py:            return util.system("\"%s\" \"%s\"" % (editor, file_path), environ={},
hgext-rupdate/__init__.py:    res = util.system(cmd, out=cmdBuf)
hgtk/tortoisehg/hgtk/gdialog.py:            util.system(command,
hgtk/tortoisehg/hgtk/gtklib.py:        util.system('%s "%s"' % (editor, file))

> > > if not too much, we could maybe more util.system away (rename to
> > > rawsystem + add a comment pointing to ui.system?
> > >
> > > (I'm not saying we must do it. I'm asking how reasonable it would be to
> > > do so)
> >
> > It might break third-party extensions unnecessarily.
> 
> I don't think I'd worry about that too much - extension authors know
> they're building on quicksand. I don't think shelling out is
> super-common in extensions.

I guess so. I'll take marmoute's suggestion and reorganize the patches.

Regards,


More information about the Mercurial-devel mailing list