[PATCH 1 of 5 V3] help: internals topic for wire protocol

Gregory Szorc gregory.szorc at gmail.com
Tue Aug 23 02:51:07 UTC 2016


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1471920399 25200
#      Mon Aug 22 19:46:39 2016 -0700
# Node ID 75d4d3cf05a8ec8daca3b790f275cced9814e892
# Parent  b1809f5d7630a3fff0fa715bbd30dba0f07672a8
help: internals topic for wire protocol

The Mercurial wire protocol is under-documented. This includes a lack
of source docstrings and comments as well as pages on the official
wiki.

This patch adds the beginnings of "internals" documentation on the
wire protocol.

The documentation should have nearly complete coverage on the
lower-level parts of the protocol, such as the different transport
mechanims, how commands and arguments are sent, capabilities, and,
of course, the commands themselves.

As part of writing this documentation, I discovered a number of
deficiencies in the protocol and bugs in the implementation. I've
started sending patches for some of the issues. I hope to send a lot
more.

This patch starts with the scaffolding for a new internals page.

diff --git a/contrib/wix/help.wxs b/contrib/wix/help.wxs
--- a/contrib/wix/help.wxs
+++ b/contrib/wix/help.wxs
@@ -37,16 +37,17 @@
         </Component>
 
         <Directory Id="help.internaldir" Name="internals">
           <Component Id="help.internals" Guid="$(var.help.internals.guid)" Win64='$(var.IsX64)'>
             <File Id="internals.bundles.txt"      Name="bundles.txt" KeyPath="yes" />
             <File Id="internals.changegroups.txt" Name="changegroups.txt" />
             <File Id="internals.requirements.txt" Name="requirements.txt" />
             <File Id="internals.revlogs.txt"      Name="revlogs.txt" />
+            <File Id="internals.wireprotocol.txt" Name="wireprotocol.txt" />
           </Component>
         </Directory>
 
       </Directory>
     </DirectoryRef>
   </Fragment>
 
 </Wix>
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -187,16 +187,18 @@ internalstable = sorted([
     (['bundles'], _('Bundles'),
      loaddoc('bundles', subdir='internals')),
     (['changegroups'], _('Changegroups'),
      loaddoc('changegroups', subdir='internals')),
     (['requirements'], _('Repository Requirements'),
      loaddoc('requirements', subdir='internals')),
     (['revlogs'], _('Revision Logs'),
      loaddoc('revlogs', subdir='internals')),
+    (['wireprotocol'], _('Wire Protocol'),
+     loaddoc('wireprotocol', subdir='internals')),
 ])
 
 def internalshelp(ui):
     """Generate the index for the "internals" topic."""
     lines = []
     for names, header, doc in internalstable:
         lines.append(' :%s: %s\n' % (names[0], header))
 
diff --git a/mercurial/help/internals/wireprotocol.txt b/mercurial/help/internals/wireprotocol.txt
new file mode 100644
--- /dev/null
+++ b/mercurial/help/internals/wireprotocol.txt
@@ -0,0 +1,11 @@
+The Mercurial wire protocol is a request-response based protocol
+with multiple wire representations.
+
+Each request is modeled as a command name, a dictionary of arguments, and
+optional raw input. Command arguments and their types are intrinsic
+properties of commands. So is the response type of the command. This means
+clients can't always send arbitrary arguments to servers and servers can't
+return multiple response types.
+
+The protocol is synchronous and does not support multiplexing (concurrent
+commands).
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -928,16 +928,17 @@ internals topic renders index of availab
   $ hg help internals
   Technical implementation topics
   """""""""""""""""""""""""""""""
   
        bundles       Bundles
        changegroups  Changegroups
        requirements  Repository Requirements
        revlogs       Revision Logs
+       wireprotocol  Wire Protocol
 
 sub-topics can be accessed
 
   $ hg help internals.changegroups
   Changegroups
   """"""""""""
   
       Changegroups are representations of repository revlog data, specifically
@@ -2890,16 +2891,23 @@ Sub-topic indexes rendered properly
   </td></tr>
   <tr><td>
   <a href="/help/internals.revlogs">
   revlogs
   </a>
   </td><td>
   Revision Logs
   </td></tr>
+  <tr><td>
+  <a href="/help/internals.wireprotocol">
+  wireprotocol
+  </a>
+  </td><td>
+  Wire Protocol
+  </td></tr>
   
   
   
   
   
   </table>
   </div>
   </div>


More information about the Mercurial-devel mailing list