Mercurial > evolve
comparison hgext/evolve.py @ 1076:2039385d6460
discovery: hook on the official discovery for obsmarker
This will let the discovery be done once and used by core.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Fri, 29 Aug 2014 10:13:44 +0200 |
parents | 1205f42ae54c |
children | cdfc19f25478 |
comparison
equal
deleted
inserted
replaced
1075:1205f42ae54c | 1076:2039385d6460 |
---|---|
2224 topic = 'obsmarkers exchange' | 2224 topic = 'obsmarkers exchange' |
2225 if ui.configbool('experimental', 'verbose-obsolescence-exchange', False): | 2225 if ui.configbool('experimental', 'verbose-obsolescence-exchange', False): |
2226 topic = 'OBSEXC' | 2226 topic = 'OBSEXC' |
2227 ui.progress(topic, *args, **kwargs) | 2227 ui.progress(topic, *args, **kwargs) |
2228 | 2228 |
2229 @eh.wrapfunction(exchange, '_pushdiscoveryobsmarkers') | |
2230 def _pushdiscoveryobsmarkers(orig, pushop): | |
2231 if (obsolete._enabled | |
2232 and pushop.repo.obsstore | |
2233 and 'obsolete' in pushop.remote.listkeys('namespaces')): | |
2234 repo = pushop.repo | |
2235 revs = list(repo.revs('::%ln', pushop.futureheads)) | |
2236 unfi = repo.unfiltered() | |
2237 cl = unfi.changelog | |
2238 if not pushop.remote.capable('_evoext_obshash_0'): | |
2239 # do not trust core yet | |
2240 # return orig(pushop) | |
2241 nodes = [cl.node(r) for r in revs] | |
2242 pushop.outobsmarkers = repo.obsstore.relevantmarkers(nodes) | |
2243 return | |
2244 | |
2245 common = [] | |
2246 obsexcmsg(repo.ui, "looking for common markers in %i nodes\n" | |
2247 % len(revs)) | |
2248 commonrevs = list(unfi.revs('::%ln', pushop.outgoing.commonheads)) | |
2249 common = findcommonobsmarkers(pushop.ui, unfi, pushop.remote, commonrevs) | |
2250 | |
2251 revs = list(unfi.revs('%ld - (::%ln)', revs, common)) | |
2252 nodes = [cl.node(r) for r in revs] | |
2253 pushop.outobsmarkers = repo.obsstore.relevantmarkers(nodes) | |
2229 | 2254 |
2230 @eh.wrapfunction(wireproto, 'capabilities') | 2255 @eh.wrapfunction(wireproto, 'capabilities') |
2231 def discocapabilities(orig, repo, proto): | 2256 def discocapabilities(orig, repo, proto): |
2232 """wrapper to advertise new capability""" | 2257 """wrapper to advertise new capability""" |
2233 caps = orig(repo, proto) | 2258 caps = orig(repo, proto) |
2242 oldcap, args = wireproto.commands['capabilities'] | 2267 oldcap, args = wireproto.commands['capabilities'] |
2243 def newcap(repo, proto): | 2268 def newcap(repo, proto): |
2244 return discocapabilities(oldcap, repo, proto) | 2269 return discocapabilities(oldcap, repo, proto) |
2245 wireproto.commands['capabilities'] = (newcap, args) | 2270 wireproto.commands['capabilities'] = (newcap, args) |
2246 wireproto.commands['evoext_obshash'] = (srv_obshash, 'nodes') | 2271 wireproto.commands['evoext_obshash'] = (srv_obshash, 'nodes') |
2272 olddisco = exchange.pushdiscoverymapping['obsmarker'] | |
2273 def newdisco(pushop): | |
2274 _pushdiscoveryobsmarkers(olddisco, pushop) | |
2275 exchange.pushdiscoverymapping['obsmarker'] = newdisco | |
2247 | 2276 |
2248 ### Set discovery START | 2277 ### Set discovery START |
2249 | 2278 |
2250 from mercurial import dagutil | 2279 from mercurial import dagutil |
2251 from mercurial import setdiscovery | 2280 from mercurial import setdiscovery |