Patchwork [STABLE] chgserver: spawn new process if schemes change

login
register
mail settings
Submitter Yuya Nishihara
Date Feb. 11, 2020, 11:07 a.m.
Message ID <3dcf73d0733d87e7a231.1581419278@mimosa>
Download mbox | patch
Permalink /patch/45183/
State Accepted
Headers show

Comments

Yuya Nishihara - Feb. 11, 2020, 11:07 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1581418436 -32400
#      Tue Feb 11 19:53:56 2020 +0900
# Branch stable
# Node ID 3dcf73d0733d87e7a231809d23da4883f4ab3711
# Parent  84d98fa814a8bab0dd94a133187dc9d42a5e433f
chgserver: spawn new process if schemes change

The schemes extension updates hg.schemes table. It's technically possible
for hg.repository() to look for e.g. ui.schemes instead of depending on
module-local table, but I don't think the change would make much sense
since [schemes] is usually specified in ~/.hgrc and thus it can be considered
static data.
Augie Fackler - Feb. 12, 2020, 7:32 p.m.
queued for stable, tahnks

> On Feb 11, 2020, at 06:07, Yuya Nishihara <yuya@tcha.org> wrote:
> 
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1581418436 -32400
> #      Tue Feb 11 19:53:56 2020 +0900
> # Branch stable
> # Node ID 3dcf73d0733d87e7a231809d23da4883f4ab3711
> # Parent  84d98fa814a8bab0dd94a133187dc9d42a5e433f
> chgserver: spawn new process if schemes change
> 
> The schemes extension updates hg.schemes table. It's technically possible
> for hg.repository() to look for e.g. ui.schemes instead of depending on
> module-local table, but I don't think the change would make much sense
> since [schemes] is usually specified in ~/.hgrc and thus it can be considered
> static data.
> 
> diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
> --- a/mercurial/chgserver.py
> +++ b/mercurial/chgserver.py
> @@ -83,6 +83,7 @@ def _hashlist(items):
>     b'eol',  # uses setconfig('eol', ...)
>     b'extdiff',  # uisetup will register new commands
>     b'extensions',
> +    b'schemes',  # extsetup will update global hg.schemes
> ]
> 
> _configsectionitems = [
> diff --git a/tests/test-chg.t b/tests/test-chg.t
> --- a/tests/test-chg.t
> +++ b/tests/test-chg.t
> @@ -245,6 +245,54 @@ is different when using py3):
>   YYYY/MM/DD HH:MM:SS (PID)> worker process exited (pid=...)
>   YYYY/MM/DD HH:MM:SS (PID)> $TESTTMP/extreload/chgsock/server-... is not owned, exiting.
> 
> +global data mutated by schems
> +-----------------------------
> +
> +  $ hg init schemes
> +  $ cd schemes
> +
> +initial state
> +
> +  $ cat > .hg/hgrc <<'EOF'
> +  > [extensions]
> +  > schemes =
> +  > [schemes]
> +  > foo = https://foo.example.org/
> +  > EOF
> +  $ hg debugexpandscheme foo://expanded
> +  https://foo.example.org/expanded
> +  $ hg debugexpandscheme bar://unexpanded
> +  bar://unexpanded
> +
> +add bar
> +
> +  $ cat > .hg/hgrc <<'EOF'
> +  > [extensions]
> +  > schemes =
> +  > [schemes]
> +  > foo = https://foo.example.org/
> +  > bar = https://bar.example.org/
> +  > EOF
> +  $ hg debugexpandscheme foo://expanded
> +  https://foo.example.org/expanded
> +  $ hg debugexpandscheme bar://expanded
> +  https://bar.example.org/expanded
> +
> +remove foo
> +
> +  $ cat > .hg/hgrc <<'EOF'
> +  > [extensions]
> +  > schemes =
> +  > [schemes]
> +  > bar = https://bar.example.org/
> +  > EOF
> +  $ hg debugexpandscheme foo://unexpanded
> +  foo://unexpanded
> +  $ hg debugexpandscheme bar://expanded
> +  https://bar.example.org/expanded
> +
> +  $ cd ..
> +
> repository cache
> ----------------
> 
> @@ -317,6 +365,8 @@ shut down servers and restore environmen
> check server log:
> 
>   $ cat log/server.log | filterlog
> +  YYYY/MM/DD HH:MM:SS (PID)> worker process exited (pid=...)
> +  YYYY/MM/DD HH:MM:SS (PID)> worker process exited (pid=...)
>   YYYY/MM/DD HH:MM:SS (PID)> init cached
>   YYYY/MM/DD HH:MM:SS (PID)> id -R cached
>   YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in  ...s)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
--- a/mercurial/chgserver.py
+++ b/mercurial/chgserver.py
@@ -83,6 +83,7 @@  def _hashlist(items):
     b'eol',  # uses setconfig('eol', ...)
     b'extdiff',  # uisetup will register new commands
     b'extensions',
+    b'schemes',  # extsetup will update global hg.schemes
 ]
 
 _configsectionitems = [
diff --git a/tests/test-chg.t b/tests/test-chg.t
--- a/tests/test-chg.t
+++ b/tests/test-chg.t
@@ -245,6 +245,54 @@  is different when using py3):
   YYYY/MM/DD HH:MM:SS (PID)> worker process exited (pid=...)
   YYYY/MM/DD HH:MM:SS (PID)> $TESTTMP/extreload/chgsock/server-... is not owned, exiting.
 
+global data mutated by schems
+-----------------------------
+
+  $ hg init schemes
+  $ cd schemes
+
+initial state
+
+  $ cat > .hg/hgrc <<'EOF'
+  > [extensions]
+  > schemes =
+  > [schemes]
+  > foo = https://foo.example.org/
+  > EOF
+  $ hg debugexpandscheme foo://expanded
+  https://foo.example.org/expanded
+  $ hg debugexpandscheme bar://unexpanded
+  bar://unexpanded
+
+add bar
+
+  $ cat > .hg/hgrc <<'EOF'
+  > [extensions]
+  > schemes =
+  > [schemes]
+  > foo = https://foo.example.org/
+  > bar = https://bar.example.org/
+  > EOF
+  $ hg debugexpandscheme foo://expanded
+  https://foo.example.org/expanded
+  $ hg debugexpandscheme bar://expanded
+  https://bar.example.org/expanded
+
+remove foo
+
+  $ cat > .hg/hgrc <<'EOF'
+  > [extensions]
+  > schemes =
+  > [schemes]
+  > bar = https://bar.example.org/
+  > EOF
+  $ hg debugexpandscheme foo://unexpanded
+  foo://unexpanded
+  $ hg debugexpandscheme bar://expanded
+  https://bar.example.org/expanded
+
+  $ cd ..
+
 repository cache
 ----------------
 
@@ -317,6 +365,8 @@  shut down servers and restore environmen
 check server log:
 
   $ cat log/server.log | filterlog
+  YYYY/MM/DD HH:MM:SS (PID)> worker process exited (pid=...)
+  YYYY/MM/DD HH:MM:SS (PID)> worker process exited (pid=...)
   YYYY/MM/DD HH:MM:SS (PID)> init cached
   YYYY/MM/DD HH:MM:SS (PID)> id -R cached
   YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in  ...s)