simple4server: add origin and documentation to most function
authorPierre-Yves David <pierre-yves.david@fb.com>
Mon, 10 Mar 2014 17:40:38 -0700
changeset 874 19a7ed6384a9
parent 873 c758717ff3c7
child 875 10867a8e27c6
simple4server: add origin and documentation to most function
hgext/simple4server.py
--- a/hgext/simple4server.py	Mon Mar 10 16:54:08 2014 -0700
+++ b/hgext/simple4server.py	Mon Mar 10 17:40:38 2014 -0700
@@ -24,8 +24,9 @@
 from mercurial.hgweb import hgweb_mod
 _pack = struct.pack
 
+# from evolve extension: 1a23c7c52a43
 def srv_pushobsmarkers(repo, proto):
-    """wireprotocol command"""
+    """That receives a stream of markers and apply then to the repo"""
     fp = StringIO()
     proto.redirect()
     proto.getfile(fp)
@@ -43,12 +44,19 @@
         lock.release()
     return wireproto.pushres(0)
 
+# from mercurial.obsolete: 19e9478c1a22
 def _encodemarkersstream(fp, markers):
+    """write a binary version of a set of markers
+
+    Includes the initial version number"""
     fp.write(_pack('>B', 0))
     for mark in markers:
         fp.write(obsolete._encodeonemarker(mark))
 
+# from evolve extension: 1a23c7c52a43
 def _getobsmarkersstream(repo, heads=None, common=None):
+    """Get a binary stream for all markers relevant to `::<heads> - ::<common>`
+    """
     revset = ''
     args = []
     repo = repo.unfiltered()
@@ -69,7 +77,12 @@
     obsdata.seek(0)
     return obsdata
 
+# from evolve extension: 1a23c7c52a43
 class pruneobsstore(obsolete.obsstore):
+    """And extended obsstore class that read parent information from v1 format
+
+    Evolve extension adds parent information in prune marker. We use it to make
+    markers relevant to pushed changeset."""
 
     def __init__(self, *args, **kwargs):
         self.prunedchildren = {}
@@ -92,6 +105,7 @@
                     self.prunedchildren.setdefault(p2, set()).add(m)
             yield m
 
+# from evolve extension: 1a23c7c52a43
 def relevantmarkers(self, nodes):
     """return a set of all obsolescence marker relevant to a set of node.
 
@@ -101,7 +115,7 @@
     - prune marker of direct children on this changeset.
     - recursive application of the two rules on precursors of these markers
 
-    It  a set so you cannot rely on order"""
+    It is a set so you cannot rely on order"""
     seennodes = set(nodes)
     seenmarkers = set()
     pendingnodes = set(nodes)
@@ -119,7 +133,13 @@
         seennodes |= pendingnodes
     return seenmarkers
 
+# from evolve extension: 1a23c7c52a43
 def srv_pullobsmarkers(repo, proto, others):
+    """serves a binary stream of markers.
+
+    Serves relevant to changeset between heads and common. The stream is prefix
+    by a -string- representation of an integer. This integer is the size of the
+    stream."""
     opts = wireproto.options('', ['heads', 'common'], others)
     for k, v in opts.iteritems():
         if k in ('heads', 'common'):
@@ -133,7 +153,11 @@
     return wireproto.streamres(data())
 
 
+# from evolve extension: 1a23c7c52a43
 def _obsrelsethashtree(repo):
+    """Build an obshash for every node in a repo
+
+    return a [(node), (obshash)] list. in revision order."""
     cache = []
     unfi = repo.unfiltered()
     for i in unfi:
@@ -163,14 +187,23 @@
             cache.append((ctx.node(), node.nullid))
     return cache
 
+# from evolve extension: 1a23c7c52a43
 def _obshash(repo, nodes):
+    """hash of binary version of relevant markers + obsparent
+
+    (special case so that all empty are hashed as nullid)"""
     hashs = _obsrelsethashtree(repo)
     nm = repo.changelog.nodemap
     return  [hashs[nm.get(n)][1] for n in nodes]
 
+# from evolve extension: 1a23c7c52a43
 def srv_obshash(repo, proto, nodes):
+    """give the obshash of a a set of node
+
+    Used for markes discovery"""
     return wireproto.encodelist(_obshash(repo, wireproto.decodelist(nodes)))
 
+# from evolve extension: 1a23c7c52a43
 def capabilities(orig, repo, proto):
     """wrapper to advertise new capability"""
     caps = orig(repo, proto)
@@ -180,6 +213,8 @@
         caps += ' _evoext_obshash_0'
     return caps
 
+# from evolve extension: 1a23c7c52a43
+# heavily modified
 def extsetup(ui):
     obsolete.obsstore = pruneobsstore
     obsolete.obsstore.relevantmarkers = relevantmarkers