diff -r deed5edb72de -r ec7fc110faee mercurial/bundle2.py --- a/mercurial/bundle2.py Mon Mar 24 12:25:33 2014 -0700 +++ b/mercurial/bundle2.py Mon Mar 24 15:51:00 2014 -0700 @@ -148,8 +148,23 @@ """ return '>'+('BB'*nbparams) +parthandlermapping = {} -parthandlermapping = {} +def parthandler(parttype): + """decorator that register a function as a bundle2 part handler + + eg:: + + @parthandler('myparttype') + def myparttypehandler(...): + '''process a part of type "my part".''' + ... + """ + def _decorator(func): + assert parttype not in parthandlermapping + parthandlermapping[parttype] = func + return func + return _decorator def processbundle(repo, stream): """This function process a bundle, apply effect to/from a repo