From patchwork Sun Mar 19 18:36:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: dispatch: replace mayberepr with shellquote From: Augie Fackler X-Patchwork-Id: 19460 Message-Id: <720555b5145c80703e4a.1489948592@imladris.local> To: mercurial-devel@mercurial-scm.org Date: Sun, 19 Mar 2017 14:36:32 -0400 # HG changeset patch # User Augie Fackler # Date 1489947810 14400 # Sun Mar 19 14:23:30 2017 -0400 # Node ID 720555b5145c80703e4a9b668c8a11a38434e9da # Parent a369482e9649478cbab5b08a204406a10ee66588 dispatch: replace mayberepr with shellquote The quoting logic here was actually insufficient, and would have had bogus b-prefixes on Python 3. shellquote seems more appropriate anyway. Surprisingly, only two tests have output changes, and both of them look reasonable to me (both are in blackbox logs). Spotted by Yuya during review. diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -92,13 +92,8 @@ def _formatparse(write, inst): if inst.hint: write(_("(%s)\n") % inst.hint) -def _mayberepr(a): - if ' ' in a: - return encoding.strtolocal(repr(a)) - return a - def _formatargs(args): - return ' '.join(_mayberepr(a) for a in args) + return ' '.join(util.shellquote(a) for a in args) def dispatch(req): "run the command specified in req.args" diff --git a/tests/test-blackbox.t b/tests/test-blackbox.t --- a/tests/test-blackbox.t +++ b/tests/test-blackbox.t @@ -25,7 +25,7 @@ alias expansion is logged 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a exited 0 after * seconds (glob) 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000+ (5000)> blackbox - 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000+ (5000)> blackbox --config blackbox.dirty=True exited 0 after * seconds (glob) + 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000+ (5000)> blackbox --config 'blackbox.dirty=True' exited 0 after * seconds (glob) 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> confuse 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> alias 'confuse' expands to 'log --limit 3' 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> confuse exited 0 after * seconds (glob) diff --git a/tests/test-devel-warnings.t b/tests/test-devel-warnings.t --- a/tests/test-devel-warnings.t +++ b/tests/test-devel-warnings.t @@ -139,7 +139,7 @@ $ hg blackbox -l 9 1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> devel-warn: revset "oldstyle" uses list instead of smartset (compatibility will be dropped after Mercurial-3.9, update your code.) at: *mercurial/revset.py:* (mfunc) (glob) - 1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> log -r oldstyle() -T {rev}\n exited 0 after * seconds (glob) + 1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> log -r 'oldstyle()' -T '{rev}\n' exited 0 after * seconds (glob) 1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> oldanddeprecated 1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> devel-warn: foorbar is deprecated, go shopping (compatibility will be dropped after Mercurial-42.1337, update your code.) at: $TESTTMP/buggylocking.py:* (oldanddeprecated) (glob)