discovery: first version of the "hash tree" idea
authorPierre-Yves David <pierre-yves.david@fb.com>
Wed, 05 Mar 2014 16:58:56 -0800
changeset 863 e9693738f234
parent 862 f954e331d511
child 864 401da1b38cca
discovery: first version of the "hash tree" idea We build a hash for each node based on the markers that applies to it and the hash of its parent. This will allow a kind of discovery process for markers.
hgext/evolve.py
--- a/hgext/evolve.py	Tue Mar 04 11:34:38 2014 -0800
+++ b/hgext/evolve.py	Wed Mar 05 16:58:56 2014 -0800
@@ -2304,6 +2304,50 @@
         caps += ' _evoext_pullobsmarkers_0'
     return caps
 
+def _obsrelsethashtree(repo):
+    cache = []
+    unfi = repo.unfiltered()
+    for i in unfi:
+        ctx = unfi[i]
+        entry = 0
+        sha = util.sha1()
+        # add data from p1
+        for p in ctx.parents():
+            p = p.rev()
+            if p < 0:
+                p = nullid
+            else:
+                p = cache[p][1]
+            if p != nullid:
+                entry += 1
+                sha.update(p)
+        tmarkers = repo.obsstore.relevantmarkers([ctx.node()])
+        if tmarkers:
+            bmarkers = [obsolete._encodeonemarker(m) for m in tmarkers]
+            bmarkers.sort()
+            for m in bmarkers:
+                entry += 1
+                sha.update(m)
+        if entry:
+            cache.append((ctx.node(), sha.digest()))
+        else:
+            cache.append((ctx.node(), nullid))
+    return cache
+
+@command('debugobsrelsethashtree',
+        [] , _(''))
+def debugobsrelsethashtree(ui, repo):
+    """display Obsolete markers, Relevant Set, Hash Tree
+    changeset-node obsrelsethashtree-node
+
+    It computed form the "orsht" of its parent and markers
+    relevant to the changeset itself."""
+    for chg, obs in _obsrelsethashtree(repo):
+        ui.status('%s %s\n' % (node.hex(chg), node.hex(obs)))
+
+
+
+
 @eh.extsetup
 def _installwireprotocol(ui):
     localrepo.MODERNCAPS.add('_evoext_pullobsmarkers_0')