Skip to content
Snippets Groups Projects
Commit dae236906fb2 authored by Pierre-Yves David's avatar Pierre-Yves David
Browse files

pull: make discovery phase extensible

We apply the same approach as for push and make the discovery extensible. There
is only one user in core right now, but we already know we'll need something
smarter for obsmarkers. In fact the evolve extension could use this to cleanly
extend discovery.

The main motivation for this change is consistency between push and pull.
parent ee297602a208
No related branches found
No related tags found
No related merge requests found
......@@ -868,4 +868,28 @@
return pullop
# list of steps to perform discovery before pull
pulldiscoveryorder = []
# Mapping between step name and function
#
# This exists to help extensions wrap steps if necessary
pulldiscoverymapping = {}
def pulldiscovery(stepname):
"""decorator for function performing discovery before pull
The function is added to the step -> function mapping and appended to the
list of steps. Beware that decorated function will be added in order (this
may matter).
You can only use this decorator for a new step, if you want to wrap a step
from an extension, change the pulldiscovery dictionary directly."""
def dec(func):
assert stepname not in pulldiscoverymapping
pulldiscoverymapping[stepname] = func
pulldiscoveryorder.append(stepname)
return func
return dec
def _pulldiscovery(pullop):
......@@ -871,4 +895,11 @@
def _pulldiscovery(pullop):
"""Run all discovery steps"""
for stepname in pulldiscoveryorder:
step = pulldiscoverymapping[stepname]
step(pullop)
@pulldiscovery('changegroup')
def _pulldiscoverychangegroup(pullop):
"""discovery phase for the pull
Current handle changeset discovery only, will change handle all discovery
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment