Mercurial > evolve
comparison hgext/evolve.py @ 863:e9693738f234
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.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 05 Mar 2014 16:58:56 -0800 |
parents | b6337585ae25 |
children | 401da1b38cca |
comparison
equal
deleted
inserted
replaced
862:f954e331d511 | 863:e9693738f234 |
---|---|
2302 if obsolete._enabled: | 2302 if obsolete._enabled: |
2303 caps += ' _evoext_pushobsmarkers_0' | 2303 caps += ' _evoext_pushobsmarkers_0' |
2304 caps += ' _evoext_pullobsmarkers_0' | 2304 caps += ' _evoext_pullobsmarkers_0' |
2305 return caps | 2305 return caps |
2306 | 2306 |
2307 def _obsrelsethashtree(repo): | |
2308 cache = [] | |
2309 unfi = repo.unfiltered() | |
2310 for i in unfi: | |
2311 ctx = unfi[i] | |
2312 entry = 0 | |
2313 sha = util.sha1() | |
2314 # add data from p1 | |
2315 for p in ctx.parents(): | |
2316 p = p.rev() | |
2317 if p < 0: | |
2318 p = nullid | |
2319 else: | |
2320 p = cache[p][1] | |
2321 if p != nullid: | |
2322 entry += 1 | |
2323 sha.update(p) | |
2324 tmarkers = repo.obsstore.relevantmarkers([ctx.node()]) | |
2325 if tmarkers: | |
2326 bmarkers = [obsolete._encodeonemarker(m) for m in tmarkers] | |
2327 bmarkers.sort() | |
2328 for m in bmarkers: | |
2329 entry += 1 | |
2330 sha.update(m) | |
2331 if entry: | |
2332 cache.append((ctx.node(), sha.digest())) | |
2333 else: | |
2334 cache.append((ctx.node(), nullid)) | |
2335 return cache | |
2336 | |
2337 @command('debugobsrelsethashtree', | |
2338 [] , _('')) | |
2339 def debugobsrelsethashtree(ui, repo): | |
2340 """display Obsolete markers, Relevant Set, Hash Tree | |
2341 changeset-node obsrelsethashtree-node | |
2342 | |
2343 It computed form the "orsht" of its parent and markers | |
2344 relevant to the changeset itself.""" | |
2345 for chg, obs in _obsrelsethashtree(repo): | |
2346 ui.status('%s %s\n' % (node.hex(chg), node.hex(obs))) | |
2347 | |
2348 | |
2349 | |
2350 | |
2307 @eh.extsetup | 2351 @eh.extsetup |
2308 def _installwireprotocol(ui): | 2352 def _installwireprotocol(ui): |
2309 localrepo.MODERNCAPS.add('_evoext_pullobsmarkers_0') | 2353 localrepo.MODERNCAPS.add('_evoext_pullobsmarkers_0') |
2310 wireproto.commands['evoext_pushobsmarkers_0'] = (srv_pushobsmarkers, '') | 2354 wireproto.commands['evoext_pushobsmarkers_0'] = (srv_pushobsmarkers, '') |
2311 wireproto.commands['evoext_pullobsmarkers_0'] = (srv_pullobsmarkers, '*') | 2355 wireproto.commands['evoext_pullobsmarkers_0'] = (srv_pullobsmarkers, '*') |