D5946: server: allow customizing the default repo filter

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

D5946: server: allow customizing the default repo filter

pulkit (Pulkit Goyal)
joerg.sonnenberger created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  hgweb has the (undocument) configuration option web.view that allows
  restricting visible revisions to immutable. This is useful for serving
  the same storage as publishing and non-publishing repo. Add the new
  server.view option to serve the same purpose by changing the default
  behavior of `getdispatchrepo`. Drop the hard-coded 'served' filter in the
  batch handler of v1 of the wire proto, this is a left-over from the days
  before `getdispatchrepo` existed.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5946

AFFECTED FILES
  mercurial/configitems.py
  mercurial/help/config.txt
  mercurial/wireprotov1server.py
  mercurial/wireprotov2server.py
  tests/test-wireproto.py

CHANGE DETAILS

diff --git a/tests/test-wireproto.py b/tests/test-wireproto.py
--- a/tests/test-wireproto.py
+++ b/tests/test-wireproto.py
@@ -78,6 +78,9 @@
         yield unmangle(f.value)
 
 class serverrepo(object):
+    def __init__(self, ui):
+        self.ui = ui
+
     def greet(self, name):
         return b"Hello, " + name
 
@@ -94,7 +97,7 @@
 
 wireprotov1server.commands[b'greet'] = (greet, b'name')
 
-srv = serverrepo()
+srv = serverrepo(uimod.ui())
 clt = clientpeer(srv, uimod.ui())
 
 def printb(data, end=b'\n'):
diff --git a/mercurial/wireprotov2server.py b/mercurial/wireprotov2server.py
--- a/mercurial/wireprotov2server.py
+++ b/mercurial/wireprotov2server.py
@@ -342,7 +342,8 @@
                                      action)
 
 def getdispatchrepo(repo, proto, command):
-    return repo.filtered('served')
+    viewconfig = repo.ui.config('server', 'view')
+    return repo.filtered(viewconfig)
 
 def dispatch(repo, proto, command, redirect):
     """Run a wire protocol command.
diff --git a/mercurial/wireprotov1server.py b/mercurial/wireprotov1server.py
--- a/mercurial/wireprotov1server.py
+++ b/mercurial/wireprotov1server.py
@@ -64,7 +64,8 @@
     extensions that need commands to operate on different repo views under
     specialized circumstances.
     """
-    return repo.filtered('served')
+    viewconfig = repo.ui.config('server', 'view')
+    return repo.filtered(viewconfig)
 
 def dispatch(repo, proto, command):
     repo = getdispatchrepo(repo, proto, command)
@@ -166,7 +167,6 @@
 @wireprotocommand('batch', 'cmds *', permission='pull')
 def batch(repo, proto, cmds, others):
     unescapearg = wireprototypes.unescapebatcharg
-    repo = repo.filtered("served")
     res = []
     for pair in cmds.split(';'):
         op, args = pair.split(' ', 1)
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -1990,6 +1990,12 @@
 
     See also ``server.zliblevel``.
 
+```view```
+    Repository filter used when exchanging revisions with the peer.
+
+    The default view (``served``) excludes secret and hidden changesets.
+    Another useful value is ``immutable`` (no draft, secret or hidden changesets).
+
 ``smtp``
 --------
 
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1029,6 +1029,9 @@
 coreconfigitem('server', 'uncompressedallowsecret',
     default=False,
 )
+coreconfigitem('server', 'view',
+    default='served',
+)
 coreconfigitem('server', 'validate',
     default=False,
 )



To: joerg.sonnenberger, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D5946: server: allow customizing the default repo filter

pulkit (Pulkit Goyal)
joerg.sonnenberger updated this revision to Diff 14072.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5946?vs=14047&id=14072

REVISION DETAIL
  https://phab.mercurial-scm.org/D5946

AFFECTED FILES
  mercurial/configitems.py
  mercurial/help/config.txt
  mercurial/wireprotov1server.py
  mercurial/wireprotov2server.py
  tests/test-server-view.t
  tests/test-wireproto.py

CHANGE DETAILS

diff --git a/tests/test-wireproto.py b/tests/test-wireproto.py
--- a/tests/test-wireproto.py
+++ b/tests/test-wireproto.py
@@ -78,6 +78,9 @@
         yield unmangle(f.value)
 
 class serverrepo(object):
+    def __init__(self, ui):
+        self.ui = ui
+
     def greet(self, name):
         return b"Hello, " + name
 
@@ -94,7 +97,7 @@
 
 wireprotov1server.commands[b'greet'] = (greet, b'name')
 
-srv = serverrepo()
+srv = serverrepo(uimod.ui())
 clt = clientpeer(srv, uimod.ui())
 
 def printb(data, end=b'\n'):
diff --git a/tests/test-server-view.t b/tests/test-server-view.t
new file mode 100644
--- /dev/null
+++ b/tests/test-server-view.t
@@ -0,0 +1,38 @@
+  $ hg init test
+  $ cd test
+  $ hg debugbuilddag '+2'
+  $ hg phase --public 0
+
+  $ hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
+  $ cat hg.pid >> $DAEMON_PIDS
+  $ cd ..
+  $ hg init test2
+  $ cd test2
+  $ hg incoming <a href="http://foo:xyzzy@localhost:$HGPORT/">http://foo:xyzzy@localhost:$HGPORT/
+  comparing with <a href="http://foo:***@localhost:$HGPORT/">http://foo:***@localhost:$HGPORT/
+  changeset:   0:1ea73414a91b
+  user:        debugbuilddag
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     r0
+  
+  changeset:   1:66f7d451a68b
+  tag:         tip
+  user:        debugbuilddag
+  date:        Thu Jan 01 00:00:01 1970 +0000
+  summary:     r1
+  
+  $ killdaemons.py
+
+  $ cd ../test
+  $ hg --config server.view=immutable serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
+  $ cat hg.pid >> $DAEMON_PIDS
+  $ cd ../test2
+  $ hg incoming <a href="http://foo:xyzzy@localhost:$HGPORT/">http://foo:xyzzy@localhost:$HGPORT/
+  comparing with <a href="http://foo:***@localhost:$HGPORT/">http://foo:***@localhost:$HGPORT/
+  changeset:   0:1ea73414a91b
+  tag:         tip
+  user:        debugbuilddag
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     r0
+  
+  $ killdaemons.py
diff --git a/mercurial/wireprotov2server.py b/mercurial/wireprotov2server.py
--- a/mercurial/wireprotov2server.py
+++ b/mercurial/wireprotov2server.py
@@ -342,7 +342,8 @@
                                      action)
 
 def getdispatchrepo(repo, proto, command):
-    return repo.filtered('served')
+    viewconfig = repo.ui.config('server', 'view')
+    return repo.filtered(viewconfig)
 
 def dispatch(repo, proto, command, redirect):
     """Run a wire protocol command.
diff --git a/mercurial/wireprotov1server.py b/mercurial/wireprotov1server.py
--- a/mercurial/wireprotov1server.py
+++ b/mercurial/wireprotov1server.py
@@ -64,7 +64,8 @@
     extensions that need commands to operate on different repo views under
     specialized circumstances.
     """
-    return repo.filtered('served')
+    viewconfig = repo.ui.config('server', 'view')
+    return repo.filtered(viewconfig)
 
 def dispatch(repo, proto, command):
     repo = getdispatchrepo(repo, proto, command)
@@ -166,7 +167,6 @@
 @wireprotocommand('batch', 'cmds *', permission='pull')
 def batch(repo, proto, cmds, others):
     unescapearg = wireprototypes.unescapebatcharg
-    repo = repo.filtered("served")
     res = []
     for pair in cmds.split(';'):
         op, args = pair.split(' ', 1)
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -1990,6 +1990,12 @@
 
     See also ``server.zliblevel``.
 
+``view``
+    Repository filter used when exchanging revisions with the peer.
+
+    The default view (``served``) excludes secret and hidden changesets.
+    Another useful value is ``immutable`` (no draft, secret or hidden changesets).
+
 ``smtp``
 --------
 
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1029,6 +1029,9 @@
 coreconfigitem('server', 'uncompressedallowsecret',
     default=False,
 )
+coreconfigitem('server', 'view',
+    default='served',
+)
 coreconfigitem('server', 'validate',
     default=False,
 )



To: joerg.sonnenberger, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D5946: server: allow customizing the default repo filter

pulkit (Pulkit Goyal)
In reply to this post by pulkit (Pulkit Goyal)
joerg.sonnenberger added a comment.


  Friendly ping

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5946

To: joerg.sonnenberger, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D5946: server: allow customizing the default repo filter

pulkit (Pulkit Goyal)
In reply to this post by pulkit (Pulkit Goyal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGd6569f1e9b37: server: allow customizing the default repo filter (authored by joerg.sonnenberger, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5946?vs=14072&id=14345

REVISION DETAIL
  https://phab.mercurial-scm.org/D5946

AFFECTED FILES
  mercurial/configitems.py
  mercurial/help/config.txt
  mercurial/wireprotov1server.py
  mercurial/wireprotov2server.py
  tests/test-server-view.t
  tests/test-wireproto.py

CHANGE DETAILS

diff --git a/tests/test-wireproto.py b/tests/test-wireproto.py
--- a/tests/test-wireproto.py
+++ b/tests/test-wireproto.py
@@ -78,6 +78,9 @@
         yield unmangle(f.value)
 
 class serverrepo(object):
+    def __init__(self, ui):
+        self.ui = ui
+
     def greet(self, name):
         return b"Hello, " + name
 
@@ -94,7 +97,7 @@
 
 wireprotov1server.commands[b'greet'] = (greet, b'name')
 
-srv = serverrepo()
+srv = serverrepo(uimod.ui())
 clt = clientpeer(srv, uimod.ui())
 
 def printb(data, end=b'\n'):
diff --git a/tests/test-server-view.t b/tests/test-server-view.t
new file mode 100644
--- /dev/null
+++ b/tests/test-server-view.t
@@ -0,0 +1,38 @@
+  $ hg init test
+  $ cd test
+  $ hg debugbuilddag '+2'
+  $ hg phase --public 0
+
+  $ hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
+  $ cat hg.pid >> $DAEMON_PIDS
+  $ cd ..
+  $ hg init test2
+  $ cd test2
+  $ hg incoming <a href="http://foo:xyzzy@localhost:$HGPORT/">http://foo:xyzzy@localhost:$HGPORT/
+  comparing with <a href="http://foo:***@localhost:$HGPORT/">http://foo:***@localhost:$HGPORT/
+  changeset:   0:1ea73414a91b
+  user:        debugbuilddag
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     r0
+  
+  changeset:   1:66f7d451a68b
+  tag:         tip
+  user:        debugbuilddag
+  date:        Thu Jan 01 00:00:01 1970 +0000
+  summary:     r1
+  
+  $ killdaemons.py
+
+  $ cd ../test
+  $ hg --config server.view=immutable serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
+  $ cat hg.pid >> $DAEMON_PIDS
+  $ cd ../test2
+  $ hg incoming <a href="http://foo:xyzzy@localhost:$HGPORT/">http://foo:xyzzy@localhost:$HGPORT/
+  comparing with <a href="http://foo:***@localhost:$HGPORT/">http://foo:***@localhost:$HGPORT/
+  changeset:   0:1ea73414a91b
+  tag:         tip
+  user:        debugbuilddag
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     r0
+  
+  $ killdaemons.py
diff --git a/mercurial/wireprotov2server.py b/mercurial/wireprotov2server.py
--- a/mercurial/wireprotov2server.py
+++ b/mercurial/wireprotov2server.py
@@ -342,7 +342,8 @@
                                      action)
 
 def getdispatchrepo(repo, proto, command):
-    return repo.filtered('served')
+    viewconfig = repo.ui.config('server', 'view')
+    return repo.filtered(viewconfig)
 
 def dispatch(repo, proto, command, redirect):
     """Run a wire protocol command.
diff --git a/mercurial/wireprotov1server.py b/mercurial/wireprotov1server.py
--- a/mercurial/wireprotov1server.py
+++ b/mercurial/wireprotov1server.py
@@ -64,7 +64,8 @@
     extensions that need commands to operate on different repo views under
     specialized circumstances.
     """
-    return repo.filtered('served')
+    viewconfig = repo.ui.config('server', 'view')
+    return repo.filtered(viewconfig)
 
 def dispatch(repo, proto, command):
     repo = getdispatchrepo(repo, proto, command)
@@ -166,7 +167,6 @@
 @wireprotocommand('batch', 'cmds *', permission='pull')
 def batch(repo, proto, cmds, others):
     unescapearg = wireprototypes.unescapebatcharg
-    repo = repo.filtered("served")
     res = []
     for pair in cmds.split(';'):
         op, args = pair.split(' ', 1)
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -2028,6 +2028,12 @@
 
     See also ``server.zliblevel``.
 
+``view``
+    Repository filter used when exchanging revisions with the peer.
+
+    The default view (``served``) excludes secret and hidden changesets.
+    Another useful value is ``immutable`` (no draft, secret or hidden changesets).
+
 ``smtp``
 --------
 
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1041,6 +1041,9 @@
 coreconfigitem('server', 'uncompressedallowsecret',
     default=False,
 )
+coreconfigitem('server', 'view',
+    default='served',
+)
 coreconfigitem('server', 'validate',
     default=False,
 )



To: joerg.sonnenberger, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel