Patchwork chgserver: drop old hack to recreate ui on HGPLAIN change

login
register
mail settings
Submitter Yuya Nishihara
Date March 20, 2016, 6:11 p.m.
Message ID <d48c308243acd89b97cb.1458497498@mimosa>
Download mbox | patch
Permalink /patch/13983/
State Accepted
Headers show

Comments

Yuya Nishihara - March 20, 2016, 6:11 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1458495855 25200
#      Sun Mar 20 10:44:15 2016 -0700
# Node ID d48c308243acd89b97cb1dc056a0ae979c80a795
# Parent  0e7a929754aa4510e946dec8eba1cc79f9558361
chgserver: drop old hack to recreate ui on HGPLAIN change

It's been superseded by config/env hash. A log message is simplified as we no
longer need a diff of environment variables. Also, _loadnewui() is changed to
require args since it can't copy old --config values without args.
Jun Wu - March 20, 2016, 9:05 p.m.
Looks good to me. I didn't clean this up because I thought it could be
useful when chgserver.skiphash = True.

I just noticed in my recent patch, "args = args[:]" was moved to a wrong
location. I will fix that later.


On 03/20/2016 11:11 AM, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1458495855 25200
> #      Sun Mar 20 10:44:15 2016 -0700
> # Node ID d48c308243acd89b97cb1dc056a0ae979c80a795
> # Parent  0e7a929754aa4510e946dec8eba1cc79f9558361
> chgserver: drop old hack to recreate ui on HGPLAIN change
>
> It's been superseded by config/env hash. A log message is simplified as we no
> longer need a diff of environment variables. Also, _loadnewui() is changed to
> require args since it can't copy old --config values without args.
>
> diff --git a/hgext/chgserver.py b/hgext/chgserver.py
> --- a/hgext/chgserver.py
> +++ b/hgext/chgserver.py
> @@ -267,10 +267,7 @@ def _newchgui(srcui, csystem):
>
>       return chgui(srcui)
>
> -def _loadnewui(srcui, args=None):
> -    if not args:
> -        args = []
> -
> +def _loadnewui(srcui, args):
>       newui = srcui.__class__()
>       for a in ['fin', 'fout', 'ferr', 'environ']:
>           setattr(newui, a, getattr(srcui, a))
> @@ -524,18 +521,9 @@ class chgcmdserver(commandserver.server)
>               newenv = dict(s.split('=', 1) for s in l)
>           except ValueError:
>               raise ValueError('unexpected value in setenv request')
> -
> -        diffkeys = set(k for k in set(os.environ.keys() + newenv.keys())
> -                       if os.environ.get(k) != newenv.get(k))
> -        _log('change env: %r\n' % sorted(diffkeys))
> -
> +        _log('setenv: %r\n' % sorted(newenv.keys()))
>           os.environ.clear()
>           os.environ.update(newenv)
> -
> -        if set(['HGPLAIN', 'HGPLAINEXCEPT']) & diffkeys:
> -            # reload config so that ui.plain() takes effect
> -            self.ui, _lui = _loadnewui(self.ui)
> -
>           _clearenvaliases(commands.table)
>
>       capabilities = commandserver.server.capabilities.copy()
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_mailman_listinfo_mercurial-2Ddevel&d=CwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=goC_KEU1hoLmVFdaD4QgHA&m=BQhplQW7zKwrwQURdrTQxY7zvopjdsGx3MJk0eJmhBA&s=bIN74z8iFORM5Et_5tF22xFeja7B75tpacq-HCsEApY&e=
>
Pierre-Yves David - March 20, 2016, 9:14 p.m.
On 03/20/2016 02:05 PM, Jun Wu wrote:
> Looks good to me. I didn't clean this up because I thought it could be
> useful when chgserver.skiphash = True.
>
> I just noticed in my recent patch, "args = args[:]" was moved to a wrong
> location. I will fix that later.

Pushed to the clowncopter, thanks.

Patch

diff --git a/hgext/chgserver.py b/hgext/chgserver.py
--- a/hgext/chgserver.py
+++ b/hgext/chgserver.py
@@ -267,10 +267,7 @@  def _newchgui(srcui, csystem):
 
     return chgui(srcui)
 
-def _loadnewui(srcui, args=None):
-    if not args:
-        args = []
-
+def _loadnewui(srcui, args):
     newui = srcui.__class__()
     for a in ['fin', 'fout', 'ferr', 'environ']:
         setattr(newui, a, getattr(srcui, a))
@@ -524,18 +521,9 @@  class chgcmdserver(commandserver.server)
             newenv = dict(s.split('=', 1) for s in l)
         except ValueError:
             raise ValueError('unexpected value in setenv request')
-
-        diffkeys = set(k for k in set(os.environ.keys() + newenv.keys())
-                       if os.environ.get(k) != newenv.get(k))
-        _log('change env: %r\n' % sorted(diffkeys))
-
+        _log('setenv: %r\n' % sorted(newenv.keys()))
         os.environ.clear()
         os.environ.update(newenv)
-
-        if set(['HGPLAIN', 'HGPLAINEXCEPT']) & diffkeys:
-            # reload config so that ui.plain() takes effect
-            self.ui, _lui = _loadnewui(self.ui)
-
         _clearenvaliases(commands.table)
 
     capabilities = commandserver.server.capabilities.copy()