Commits

Anonymous committed 19a7ed6

simple4server: add origin and documentation to most function

Comments (0)

Files changed (1)

hgext/simple4server.py

 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)
         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()
     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 = {}
                     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.
 
     - 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)
         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'):
     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:
             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)
         caps += ' _evoext_obshash_0'
     return caps
 
+# from evolve extension: 1a23c7c52a43
+# heavily modified
 def extsetup(ui):
     obsolete.obsstore = pruneobsstore
     obsolete.obsstore.relevantmarkers = relevantmarkers