Mercurial > hg-stable
changeset 22346:a76660f85200
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.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Mon, 25 Aug 2014 19:32:51 +0200 |
parents | cf7014c5f087 |
children | 7198cb9b56b9 |
files | mercurial/exchange.py |
diffstat | 1 files changed, 14 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/exchange.py Tue Aug 26 11:36:23 2014 +0200 +++ b/mercurial/exchange.py Mon Aug 25 19:32:51 2014 +0200 @@ -37,6 +37,20 @@ else: raise util.Abort(_('%s: unknown bundle version %s') % (fname, version)) +def buildobsmarkerspart(bundler, markers): + """add an obsmarker part to the bundler with <markers> + + 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