diff mercurial/bundle2.py @ 24641:60fecc5b14a4

unbundle20: retrieve unbundler instances through a factory function To support multiple bundle2 formats, we will need a function returning the proper unbundler according to the header. We introduce such aa function and change the usage in the code base. The function will get smarter in later changesets. This is somewhat similar to the dispatching we do for 'HG10' and 'HG11'. The main target is to allow HG2Y support in an extension to ease transition of companies using the experimental protocol in production (yeah...) But I've no doubt this will be useful when playing with a future HG21.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 06 Apr 2015 16:04:33 -0700
parents 685639f9430d
children 54e5c239c2d9
line wrap: on
line diff
--- a/mercurial/bundle2.py	Mon Apr 06 15:40:12 2015 -0700
+++ b/mercurial/bundle2.py	Mon Apr 06 16:04:33 2015 -0700
@@ -521,6 +521,10 @@
         if util.safehasattr(self._fp, 'close'):
             return self._fp.close()
 
+def getunbundler(ui, fp, header=None):
+    """return a valid unbundler object for a given header"""
+    return unbundle20(ui, fp, header)
+
 class unbundle20(unpackermixin):
     """interpret a bundle2 stream