diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -769,6 +769,15 @@ fullargs = args cmd, func, args, options, cmdoptions = _parse(lui, args) + cmdname = '' + # An alias is passed, func is cmdalias object + if util.safehasattr(func, 'cmdname'): + cmdname = func.cmdname + else: + cmdname = cmd + + for ui_ in uis: + ui_.setconfig('_internal', 'command', cmdname, 'dispatch') if options["config"]: raise error.Abort(_("option --config may not be abbreviated!")) diff --git a/tests/test-basic.t b/tests/test-basic.t --- a/tests/test-basic.t +++ b/tests/test-basic.t @@ -1,9 +1,10 @@ Create a repository: $ hg config + extensions.fsmonitor= (fsmonitor !) + _internal.command=config devel.all-warnings=true devel.default-date=0 0 - extensions.fsmonitor= (fsmonitor !) largefiles.usercache=$TESTTMP/.cache/largefiles (glob) ui.slash=True ui.interactive=False diff --git a/tests/test-commandserver.t b/tests/test-commandserver.t --- a/tests/test-commandserver.t +++ b/tests/test-commandserver.t @@ -188,15 +188,17 @@ ... runcommand(server, ['init', 'foo']) ... runcommand(server, ['-R', 'foo', 'showconfig', 'ui', 'defaults']) *** runcommand showconfig + extensions.fsmonitor= (fsmonitor !) + ui.usehttp2=true (?) + ui.usehttp2=true (?) + _internal.command=config bundle.mainreporoot=$TESTTMP/repo devel.all-warnings=true devel.default-date=0 0 - extensions.fsmonitor= (fsmonitor !) largefiles.usercache=$TESTTMP/.cache/largefiles ui.slash=True ui.interactive=False ui.mergemarkers=detailed - ui.usehttp2=true (?) ui.foo=bar ui.nontty=true web.address=localhost @@ -206,7 +208,6 @@ ui.slash=True ui.interactive=False ui.mergemarkers=detailed - ui.usehttp2=true (?) ui.nontty=true $ rm -R foo diff --git a/tests/test-dispatch.t b/tests/test-dispatch.t --- a/tests/test-dispatch.t +++ b/tests/test-dispatch.t @@ -60,3 +60,44 @@ [255] #endif + +Test storing of command in ui object by wrapping the dispatch.runcommand + + $ cat > checkui.py < from mercurial import commands, registrar, util, extensions, dispatch + > cmdtable = {} + > command = registrar.command(cmdtable) + > def extsetup(): + > extensions.wrapfunction(dispatch, '_runcommand', printcommandname) + > def printcommandname(orig, ui, options, cmd, cmdfunc): + > command = ui.config('_internal', 'command') + > ui.write('%s\n' % command) + > EOF + +Enable the extension after init to make sure it works + + $ hg init testui + $ cd testui + $ echo '[extensions]' >> $HGRCPATH + $ echo "checkui = $TESTTMP/checkui.py" >> $HGRCPATH + $ hg log + log + $ hg diff + diff + +Testing short hand ones + + $ hg exp + export + $ hg ci + commit + +Testing aliases + + $ echo '[alias]' >> $HGRCPATH + $ echo "show = export" >> $HGRCPATH + $ echo "glog = log -G" >> $HGRCPATH + $ hg show + export + $ hg glog + log diff --git a/tests/test-hgrc.t b/tests/test-hgrc.t --- a/tests/test-hgrc.t +++ b/tests/test-hgrc.t @@ -45,6 +45,7 @@ $ hg paths default = $TESTTMP/foo%bar (glob) $ hg showconfig + _internal.command=config bundle.mainreporoot=$TESTTMP/foobar (glob) paths.default=$TESTTMP/foo%bar (glob) $ cd .. @@ -79,6 +80,7 @@ make sure global options given on the cmdline take precedence $ hg showconfig --config ui.verbose=True --quiet + _internal.command=config bundle.mainreporoot=$TESTTMP ui.verbose=False ui.debug=False @@ -110,6 +112,7 @@ $ cd .. $ hg showconfig + _internal.command=config bundle.mainreporoot=$TESTTMP ui.username=$FAKEUSER @@ -153,6 +156,7 @@ $ hg showconfig read config from: $TESTTMP/hgrc + dispatch: _internal.command=config $TESTTMP/hgrc:13: alias.log=log -g repo: bundle.mainreporoot=$TESTTMP $TESTTMP/hgrc:11: defaults.identify=-n @@ -170,6 +174,7 @@ $ HGPLAIN=; export HGPLAIN $ hg showconfig --config ui.traceback=True --debug read config from: $TESTTMP/hgrc + dispatch: _internal.command=config repo: bundle.mainreporoot=$TESTTMP --config: ui.traceback=True --verbose: ui.verbose=False @@ -183,6 +188,7 @@ set config by: $VISUAL set config by: $PAGER read config from: $TESTTMP/hgrc + dispatch: _internal.command=config repo: bundle.mainreporoot=$TESTTMP $PAGER: pager.pager=p1 $VISUAL: ui.editor=e2 @@ -206,6 +212,7 @@ $ hg showconfig --config ui.traceback=True --debug plain: True read config from: $TESTTMP/hgrc + dispatch: _internal.command=config repo: bundle.mainreporoot=$TESTTMP $TESTTMP/hgrc:15: extensions.plain=./plain.py --config: ui.traceback=True @@ -216,6 +223,7 @@ $ hg showconfig --config ui.traceback=True --debug plain: True read config from: $TESTTMP/hgrc + dispatch: _internal.command=config repo: bundle.mainreporoot=$TESTTMP $TESTTMP/hgrc:15: extensions.plain=./plain.py --config: ui.traceback=True @@ -226,6 +234,7 @@ $ hg showconfig --config ui.traceback=True --debug plain: True read config from: $TESTTMP/hgrc + dispatch: _internal.command=config repo: bundle.mainreporoot=$TESTTMP $TESTTMP/hgrc:15: extensions.plain=./plain.py --config: ui.traceback=True