# HG changeset patch # User Pierre-Yves David # Date 2014-08-25 17:32:51 # Node ID a76660f85200e9008284d5d69dde14af90a53fbc # Parent cf7014c5f087afb15bac1bcc5186eb15f117a451 exchange: add a `buildobsmarkerpart` function We'll have to build an obsmarker part for both push and pull. So we build a function to factor out the common part. diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -37,6 +37,20 @@ def readbundle(ui, fh, fname, vfs=None): else: raise util.Abort(_('%s: unknown bundle version %s') % (fname, version)) +def buildobsmarkerspart(bundler, markers): + """add an obsmarker part to the bundler with + + No part is created if markers is empty. + Raises ValueError if the bundler doesn't support any known obsmarker format. + """ + if markers: + remoteversions = bundle2.obsmarkersversion(bundler.capabilities) + version = obsolete.commonversion(remoteversions) + if version is None: + raise ValueError('bundler do not support common obsmarker format') + stream = obsolete.encodemarkers(markers, True, version=version) + return bundler.newpart('B2X:OBSMARKERS', data=stream) + return None class pushoperation(object): """A object that represent a single push operation