exchange: actually use _pushkeyescape fallback
authorPierre-Yves David <pierre-yves.david@fb.com>
Fri, 28 Feb 2014 10:30:10 -0800
changeset 820 a9a66143e2ec
parent 819 0b6af104fd78
child 821 202376586cf6
exchange: actually use _pushkeyescape fallback The code was still calling `obsolete._pushkeyescape` therefore never calling the fallback we defined. Now that we call it, it had to be fixed to actually work too.
hgext/evolve.py
--- a/hgext/evolve.py	Mon Mar 03 19:28:43 2014 -0800
+++ b/hgext/evolve.py	Fri Feb 28 10:30:10 2014 -0800
@@ -24,6 +24,7 @@
 
 import sys
 import random
+import struct
 
 import mercurial
 from mercurial import util
@@ -40,6 +41,7 @@
 
 
 
+from mercurial import base85
 from mercurial import bookmarks
 from mercurial import cmdutil
 from mercurial import commands
@@ -59,7 +61,9 @@
 from mercurial.i18n import _
 from mercurial.commands import walkopts, commitopts, commitopts2
 from mercurial.node import nullid
+from mercurial import wireproto
 
+_pack = struct.pack
 
 
 # This extension contains the following code
@@ -2077,6 +2081,7 @@
 
 _pushkeyescape = getattr(obsolete, '_pushkeyescape', None)
 if _pushkeyescape is None:
+    _maxpayload = 5300
     def _pushkeyescape(markers):
         """encode markers into a dict suitable for pushkey exchange
 
@@ -2085,7 +2090,7 @@
         parts = []
         currentlen = _maxpayload * 2  # ensure we create a new part
         for marker in markers:
-            nextdata = _encodeonemarker(marker)
+            nextdata = obsolete._encodeonemarker(marker)
             if (len(nextdata) + currentlen > _maxpayload):
                 currentpart = []
                 currentlen = 0
@@ -2094,7 +2099,7 @@
             currentlen += len(nextdata)
         keys = {}
         for idx, part in enumerate(reversed(parts)):
-            data = ''.join([_pack('>B', _fmversion)] + part)
+            data = ''.join([_pack('>B', 0)] + part)
             keys['dump%i' % idx] = base85.b85encode(data)
         return keys
 
@@ -2116,7 +2121,7 @@
         markers = repo.obsstore.relevantmarkers(nodes)
         rslts = []
         repo.ui.status("OBSEXC: encoding %i markers\n" % len(markers))
-        remotedata = obsolete._pushkeyescape(markers).items()
+        remotedata = _pushkeyescape(markers).items()
         totalbytes = sum(len(d) for k,d in remotedata)
         sentbytes = 0
         repo.ui.status("OBSEXC: sending %i pushkey payload (%i bytes)\n"