##// END OF EJS Templates
unbundle20: allow registering handlers for stream level parameters...
Pierre-Yves David -
r26395:4e7b0bf9 default
parent child Browse files
Show More
@@ -661,13 +661,15 b' class unbundle20(unpackermixin):'
661 661 raise ValueError('empty parameter name')
662 662 if name[0] not in string.letters:
663 663 raise ValueError('non letter first character: %r' % name)
664 # Some logic will be later added here to try to process the option for
665 # a dict of known parameter.
666 if name[0].islower():
667 indebug(self.ui, "ignoring unknown parameter %r" % name)
664 try:
665 handler = b2streamparamsmap[name.lower()]
666 except KeyError:
667 if name[0].islower():
668 indebug(self.ui, "ignoring unknown parameter %r" % name)
669 else:
670 raise error.BundleUnknownFeatureError(params=(name,))
668 671 else:
669 raise error.BundleUnknownFeatureError(params=(name,))
670
672 handler(self, name, value)
671 673
672 674 def iterparts(self):
673 675 """yield all parts contained in the stream"""
@@ -700,6 +702,16 b' class unbundle20(unpackermixin):'
700 702
701 703 formatmap = {'20': unbundle20}
702 704
705 b2streamparamsmap = {}
706
707 def b2streamparamhandler(name):
708 """register a handler for a stream level parameter"""
709 def decorator(func):
710 assert name not in formatmap
711 b2streamparamsmap[name] = func
712 return func
713 return decorator
714
703 715 class bundlepart(object):
704 716 """A bundle2 part contains application level payload
705 717
General Comments 0
You need to be logged in to leave comments. Login now