Mercurial > public > mercurial-scm > hg
comparison mercurial/dispatch.py @ 31492:3c77414a0f9c
dispatch: consolidate formatting of arguments
This was getting done twice, and it's clever enough I'm about to split
it apart and then fix it for Python 3.
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 19 Mar 2017 00:18:53 -0400 |
parents | 492c64afc54c |
children | 7e9c7d1d65cb |
comparison
equal
deleted
inserted
replaced
31491:492c64afc54c | 31492:3c77414a0f9c |
---|---|
90 write(_("hg: parse error: %s\n") % inst.args[0]) | 90 write(_("hg: parse error: %s\n") % inst.args[0]) |
91 _reportsimilar(write, similar) | 91 _reportsimilar(write, similar) |
92 if inst.hint: | 92 if inst.hint: |
93 write(_("(%s)\n") % inst.hint) | 93 write(_("(%s)\n") % inst.hint) |
94 | 94 |
95 def _formatargs(args): | |
96 return ' '.join(' ' in a and repr(a) or a for a in args) | |
97 | |
95 def dispatch(req): | 98 def dispatch(req): |
96 "run the command specified in req.args" | 99 "run the command specified in req.args" |
97 if req.ferr: | 100 if req.ferr: |
98 ferr = req.ferr | 101 ferr = req.ferr |
99 elif req.ui: | 102 elif req.ui: |
121 return -1 | 124 return -1 |
122 except error.ParseError as inst: | 125 except error.ParseError as inst: |
123 _formatparse(ferr.write, inst) | 126 _formatparse(ferr.write, inst) |
124 return -1 | 127 return -1 |
125 | 128 |
126 msg = ' '.join(' ' in a and repr(a) or a for a in req.args) | 129 msg = _formatargs(req.args) |
127 starttime = util.timer() | 130 starttime = util.timer() |
128 ret = None | 131 ret = None |
129 try: | 132 try: |
130 ret = _runcatch(req) | 133 ret = _runcatch(req) |
131 except KeyboardInterrupt: | 134 except KeyboardInterrupt: |
827 repo = repo.unfiltered() | 830 repo = repo.unfiltered() |
828 args.insert(0, repo) | 831 args.insert(0, repo) |
829 elif rpath: | 832 elif rpath: |
830 ui.warn(_("warning: --repository ignored\n")) | 833 ui.warn(_("warning: --repository ignored\n")) |
831 | 834 |
832 msg = ' '.join(' ' in a and repr(a) or a for a in fullargs) | 835 msg = _formatargs(fullargs) |
833 ui.log("command", '%s\n', msg) | 836 ui.log("command", '%s\n', msg) |
834 strcmdopt = pycompat.strkwargs(cmdoptions) | 837 strcmdopt = pycompat.strkwargs(cmdoptions) |
835 d = lambda: util.checksignature(func)(ui, *args, **strcmdopt) | 838 d = lambda: util.checksignature(func)(ui, *args, **strcmdopt) |
836 try: | 839 try: |
837 return runcommand(lui, repo, cmd, fullargs, ui, options, d, | 840 return runcommand(lui, repo, cmd, fullargs, ui, options, d, |