[PATCH 8 of 8 chgtocore] chgserver: make it a core module and drop extension flags

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Nov 23 12:32:43 EST 2016



On 11/23/2016 04:33 PM, Jun Wu wrote:
> This series look good to me. Thanks for the clean up!
> I'll continue my chg work on top of this.

This looks great, I've pushed it.

Thanks Jun for the review, this significantly lowered the latency of my 
review.

Cheers,

>
> Excerpts from Yuya Nishihara's message of 2016-11-23 01:00:01 +0900:
>> # HG changeset patch
>> # User Yuya Nishihara <yuya at tcha.org>
>> # Date 1476509416 -32400
>> #      Sat Oct 15 14:30:16 2016 +0900
>> # Node ID fd00c0d94a008dd533b99d15873320ee7e8c7286
>> # Parent  c0640366366cf076e2641ae53948be0770154611
>> chgserver: make it a core module and drop extension flags
>>
>> It was an extension just because there were several dependency cycles I
>> needed to address.
>>
>> I don't add 'chgserver' to extensions._builtin since chgserver is considered
>> an internal extension so nobody should enable it by their config.
>>
>> diff --git a/contrib/chg/Makefile b/contrib/chg/Makefile
>> --- a/contrib/chg/Makefile
>> +++ b/contrib/chg/Makefile
>> @@ -40,7 +40,6 @@ serve:
>>      [ -d $(CHGSOCKDIR) ] || ( umask 077; mkdir $(CHGSOCKDIR) )
>>      $(HG) serve --cwd / --cmdserver chgunix \
>>          --address $(CHGSOCKNAME) \
>> -        --config extensions.chgserver= \
>>          --config cmdserver.log=/dev/stderr
>>
>>  .PHONY: clean
>> diff --git a/contrib/chg/chg.c b/contrib/chg/chg.c
>> --- a/contrib/chg/chg.c
>> +++ b/contrib/chg/chg.c
>> @@ -225,7 +225,6 @@ static void execcmdserver(const struct c
>>          "--cmdserver", "chgunix",
>>          "--address", opts->sockname,
>>          "--daemon-postexec", "chdir:/",
>> -        "--config", "extensions.chgserver=",
>>      };
>>      size_t baseargvsize = sizeof(baseargv) / sizeof(baseargv[0]);
>>      size_t argsize = baseargvsize + opts->argsize + 1;
>> diff --git a/hgext/chgserver.py b/mercurial/chgserver.py
>> rename from hgext/chgserver.py
>> rename to mercurial/chgserver.py
>> --- a/hgext/chgserver.py
>> +++ b/mercurial/chgserver.py
>> @@ -5,7 +5,7 @@
>>  # This software may be used and distributed according to the terms of the
>>  # GNU General Public License version 2 or any later version.
>>
>> -"""command server extension for cHg (EXPERIMENTAL)
>> +"""command server extension for cHg
>>
>>  'S' channel (read/write)
>>      propagate ui.system() request to client
>> @@ -50,24 +50,17 @@ import struct
>>  import sys
>>  import time
>>
>> -from mercurial.i18n import _
>> +from .i18n import _
>>
>> -from mercurial import (
>> +from . import (
>>      cmdutil,
>>      commandserver,
>>      error,
>>      extensions,
>>      osutil,
>> -    server,
>>      util,
>>  )
>>
>> -# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
>> -# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
>> -# be specifying the version(s) of Mercurial they are tested with, or
>> -# leave the attribute unspecified.
>> -testedwith = 'ships-with-hg-core'
>> -
>>  _log = commandserver.log
>>
>>  def _hashlist(items):
>> @@ -123,7 +116,7 @@ def _getmtimepaths(ui):
>>      """
>>      modules = [m for n, m in extensions.extensions(ui)]
>>      try:
>> -        from mercurial import __version__
>> +        from . import __version__
>>          modules.append(__version__)
>>      except ImportError:
>>          pass
>> @@ -179,7 +172,7 @@ class hashstate(object):
>>
>>  # copied from hgext/pager.py:uisetup()
>>  def _setuppagercmd(ui, options, cmd):
>> -    from mercurial import commands  # avoid cycle
>> +    from . import commands  # avoid cycle
>>
>>      if not ui.formatted():
>>          return
>> @@ -260,7 +253,7 @@ def _newchgui(srcui, csystem):
>>      return chgui(srcui)
>>
>>  def _loadnewui(srcui, args):
>> -    from mercurial import dispatch  # avoid cycle
>> +    from . import dispatch  # avoid cycle
>>
>>      newui = srcui.__class__()
>>      for a in ['fin', 'fout', 'ferr', 'environ']:
>> @@ -268,10 +261,6 @@ def _loadnewui(srcui, args):
>>      if util.safehasattr(srcui, '_csystem'):
>>          newui._csystem = srcui._csystem
>>
>> -    # internal config: extensions.chgserver
>> -    newui.setconfig('extensions', 'chgserver',
>> -                    srcui.config('extensions', 'chgserver'), '--config')
>> -
>>      # command line args
>>      args = args[:]
>>      dispatch._parseconfig(newui, dispatch._earlygetopt(['--config'], args))
>> @@ -441,7 +430,7 @@ class chgcmdserver(commandserver.server)
>>          list, the client can continue with this server after completing all
>>          the instructions.
>>          """
>> -        from mercurial import dispatch  # avoid cycle
>> +        from . import dispatch  # avoid cycle
>>
>>          args = self._readlist()
>>          try:
>> @@ -490,7 +479,7 @@ class chgcmdserver(commandserver.server)
>>          If pager isn't enabled, this writes '\0' because channeledoutput
>>          does not allow to write empty data.
>>          """
>> -        from mercurial import dispatch  # avoid cycle
>> +        from . import dispatch  # avoid cycle
>>
>>          args = self._readlist()
>>          try:
>> @@ -645,6 +634,3 @@ def chgunixservice(ui, repo, opts):
>>          ui.setconfig('bundle', 'mainreporoot', '', 'repo')
>>      h = chgunixservicehandler(ui)
>>      return commandserver.unixforkingservice(ui, repo=None, opts=opts, handler=h)
>> -
>> -def uisetup(ui):
>> -    server._cmdservicemap['chgunix'] = chgunixservice
>> diff --git a/mercurial/server.py b/mercurial/server.py
>> --- a/mercurial/server.py
>> +++ b/mercurial/server.py
>> @@ -15,6 +15,7 @@ import tempfile
>>  from .i18n import _
>>
>>  from . import (
>> +    chgserver,
>>      commandserver,
>>      error,
>>      hgweb,
>> @@ -109,6 +110,7 @@ def runservice(opts, parentfn=None, init
>>          return runfn()
>>
>>  _cmdservicemap = {
>> +    'chgunix': chgserver.chgunixservice,
>>      'pipe': commandserver.pipeservice,
>>      'unix': commandserver.unixforkingservice,
>>  }
>> diff --git a/tests/test-basic.t b/tests/test-basic.t
>> --- a/tests/test-basic.t
>> +++ b/tests/test-basic.t
>> @@ -6,7 +6,6 @@ Create a repository:
>>    defaults.shelve=--date "0 0"
>>    defaults.tag=-d "0 0"
>>    devel.all-warnings=true
>> -  extensions.chgserver= (?)
>>    largefiles.usercache=$TESTTMP/.cache/largefiles (glob)
>>    ui.slash=True
>>    ui.interactive=False
>> diff --git a/tests/test-help.t b/tests/test-help.t
>> --- a/tests/test-help.t
>> +++ b/tests/test-help.t
>> @@ -241,7 +241,6 @@ Test extension help:
>>
>>        enabled extensions:
>>
>> -       chgserver     command server extension for cHg (EXPERIMENTAL) (?)
>>         children      command to display child changesets (DEPRECATED)
>>         rebase        command to move sets of revisions to a different ancestor
>>
>> diff --git a/tests/test-hgrc.t b/tests/test-hgrc.t
>> --- a/tests/test-hgrc.t
>> +++ b/tests/test-hgrc.t
>> @@ -46,7 +46,6 @@ Issue1199: Can't use '%' in hgrc (eg url
>>    default = $TESTTMP/foo%bar (glob)
>>    $ hg showconfig
>>    bundle.mainreporoot=$TESTTMP/foobar (glob)
>> -  extensions.chgserver= (?)
>>    paths.default=$TESTTMP/foo%bar (glob)
>>    $ cd ..
>>
>> @@ -81,7 +80,6 @@ make sure global options given on the cm
>>
>>    $ hg showconfig --config ui.verbose=True --quiet
>>    bundle.mainreporoot=$TESTTMP
>> -  extensions.chgserver= (?)
>>    ui.verbose=False
>>    ui.debug=False
>>    ui.quiet=True
>> @@ -113,7 +111,6 @@ username expansion
>>
>>    $ hg showconfig
>>    bundle.mainreporoot=$TESTTMP
>> -  extensions.chgserver= (?)
>>    ui.username=$FAKEUSER
>>
>>    $ unset FAKEUSER
>> @@ -159,7 +156,6 @@ customized hgrc
>>    $TESTTMP/hgrc:13: alias.log=log -g
>>    repo: bundle.mainreporoot=$TESTTMP
>>    $TESTTMP/hgrc:11: defaults.identify=-n
>> -  --config: extensions.chgserver= (?)
>>    $TESTTMP/hgrc:2: ui.debug=true
>>    $TESTTMP/hgrc:3: ui.fallbackencoding=ASCII
>>    $TESTTMP/hgrc:4: ui.quiet=true
>> @@ -175,7 +171,6 @@ plain hgrc
>>    $ hg showconfig --config ui.traceback=True --debug
>>    read config from: $TESTTMP/hgrc
>>    repo: bundle.mainreporoot=$TESTTMP
>> -  --config: extensions.chgserver= (?)
>>    --config: ui.traceback=True
>>    --verbose: ui.verbose=False
>>    --debug: ui.debug=True
>> @@ -199,7 +194,6 @@ plain mode with exceptions
>>    read config from: $TESTTMP/hgrc
>>    repo: bundle.mainreporoot=$TESTTMP
>>    $TESTTMP/hgrc:15: extensions.plain=./plain.py
>> -  --config: extensions.chgserver= (?)
>>    --config: ui.traceback=True
>>    --verbose: ui.verbose=False
>>    --debug: ui.debug=True
>> @@ -210,7 +204,6 @@ plain mode with exceptions
>>    read config from: $TESTTMP/hgrc
>>    repo: bundle.mainreporoot=$TESTTMP
>>    $TESTTMP/hgrc:15: extensions.plain=./plain.py
>> -  --config: extensions.chgserver= (?)
>>    --config: ui.traceback=True
>>    --verbose: ui.verbose=False
>>    --debug: ui.debug=True
>> @@ -221,7 +214,6 @@ plain mode with exceptions
>>    read config from: $TESTTMP/hgrc
>>    repo: bundle.mainreporoot=$TESTTMP
>>    $TESTTMP/hgrc:15: extensions.plain=./plain.py
>> -  --config: extensions.chgserver= (?)
>>    --config: ui.traceback=True
>>    --verbose: ui.verbose=False
>>    --debug: ui.debug=True
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list