diff mercurial/exchange.py @ 32548:e70d6dbde713

bundle2: move function building obsmarker-part in the bundle2 module We move it next to similar part building functions. We will need it for the "writenewbundle" logic. This will allow us to easily include obsmarkers in on-disk bundle, a necessary step before having `hg strip` also operate on markers. (Yes, the bundle2 module was already too large, but there any many interdependencies between its components so it is non-trivial to split, this is a quest for another adventure.)
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 28 May 2017 11:48:18 -0700
parents bd872f64a8ba
children 9929af2b09b4
line wrap: on
line diff
--- a/mercurial/exchange.py	Tue May 02 21:45:48 2017 +0900
+++ b/mercurial/exchange.py	Sun May 28 11:48:18 2017 -0700
@@ -248,21 +248,6 @@
     else:
         raise error.Abort(_('unknown bundle type: %s') % b)
 
-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 does not support common obsmarker format')
-        stream = obsolete.encodemarkers(markers, True, version=version)
-        return bundler.newpart('obsmarkers', data=stream)
-    return None
-
 def _computeoutgoing(repo, heads, common):
     """Computes which revs are outgoing given a set of common
     and a set of heads.
@@ -822,7 +807,7 @@
     pushop.stepsdone.add('obsmarkers')
     if pushop.outobsmarkers:
         markers = sorted(pushop.outobsmarkers)
-        buildobsmarkerspart(bundler, markers)
+        bundle2.buildobsmarkerspart(bundler, markers)
 
 @b2partsgenerator('bookmarks')
 def _pushb2bookmarks(pushop, bundler):
@@ -1648,7 +1633,7 @@
         subset = [c.node() for c in repo.set('::%ln', heads)]
         markers = repo.obsstore.relevantmarkers(subset)
         markers = sorted(markers)
-        buildobsmarkerspart(bundler, markers)
+        bundle2.buildobsmarkerspart(bundler, markers)
 
 @getbundle2partsgenerator('hgtagsfnodes')
 def _getbundletagsfnodes(bundler, repo, source, bundlecaps=None,