1. Pierre-Yves David
  2. mutable-history

Commits

Pierre-Yves David  committed e969373

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.

  • Participants
  • Parent commits f954e33
  • Branches default

Comments (0)

Files changed (1)

File hgext/evolve.py

View file
  • Ignore whitespace
         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')