Show More
@@ -1785,11 +1785,13 b' class localrepository(object):' | |||
|
1785 | 1785 | |
|
1786 | 1786 | self.ui.debug('fetching remote obsolete markers') |
|
1787 | 1787 | remoteobs = remote.listkeys('obsolete') |
|
1788 | if 'dump' in remoteobs: | |
|
1788 | if 'dump0' in remoteobs: | |
|
1789 | 1789 | if tr is None: |
|
1790 | 1790 | tr = self.transaction(trname) |
|
1791 | data = base85.b85decode(remoteobs['dump']) | |
|
1792 | self.obsstore.mergemarkers(tr, data) | |
|
1791 | for key in sorted(remoteobs, reverse=True): | |
|
1792 | if key.startswith('dump'): | |
|
1793 | data = base85.b85decode(remoteobs[key]) | |
|
1794 | self.obsstore.mergemarkers(tr, data) | |
|
1793 | 1795 | if tr is not None: |
|
1794 | 1796 | tr.close() |
|
1795 | 1797 | finally: |
@@ -1955,10 +1957,15 b' class localrepository(object):' | |||
|
1955 | 1957 | self.ui.debug('try to push obsolete markers to remote\n') |
|
1956 | 1958 | if (self.obsstore and |
|
1957 | 1959 | 'obsolete' in remote.listkeys('namespaces')): |
|
1958 | data = self.listkeys('obsolete')['dump'] | |
|
1959 |
r = |
|
|
1960 | if not r: | |
|
1961 | self.ui.warn(_('failed to push obsolete markers!\n')) | |
|
1960 | rslts = [] | |
|
1961 | remotedata = self.listkeys('obsolete') | |
|
1962 | for key in sorted(remotedata, reverse=True): | |
|
1963 | # reverse sort to ensure we end with dump0 | |
|
1964 | data = remotedata[key] | |
|
1965 | rslts.append(remote.pushkey('obsolete', key, '', data)) | |
|
1966 | if [r for r in rslts if not r]: | |
|
1967 | msg = _('failed to push some obsolete markers!\n') | |
|
1968 | self.ui.warn(msg) | |
|
1962 | 1969 | finally: |
|
1963 | 1970 | if lock is not None: |
|
1964 | 1971 | lock.release() |
@@ -234,24 +234,45 b' def _encodemarkers(markers, addheader=Fa' | |||
|
234 | 234 | if addheader: |
|
235 | 235 | yield _pack('>B', _fmversion) |
|
236 | 236 | for marker in markers: |
|
237 | pre, sucs, flags, metadata = marker | |
|
238 | nbsuc = len(sucs) | |
|
239 | format = _fmfixed + (_fmnode * nbsuc) | |
|
240 | data = [nbsuc, len(metadata), flags, pre] | |
|
241 | data.extend(sucs) | |
|
242 | yield _pack(format, *data) | |
|
243 | yield metadata | |
|
237 | yield _encodeonemarker(marker) | |
|
238 | ||
|
239 | ||
|
240 | def _encodeonemarker(marker): | |
|
241 | pre, sucs, flags, metadata = marker | |
|
242 | nbsuc = len(sucs) | |
|
243 | format = _fmfixed + (_fmnode * nbsuc) | |
|
244 | data = [nbsuc, len(metadata), flags, pre] | |
|
245 | data.extend(sucs) | |
|
246 | return _pack(format, *data) + metadata | |
|
247 | ||
|
248 | # arbitrary picked to fit into 8K limit from HTTP server | |
|
249 | # you have to take in account: | |
|
250 | # - the version header | |
|
251 | # - the base85 encoding | |
|
252 | _maxpayload = 5300 | |
|
244 | 253 | |
|
245 | 254 | def listmarkers(repo): |
|
246 | 255 | """List markers over pushkey""" |
|
247 | 256 | if not repo.obsstore: |
|
248 | 257 | return {} |
|
249 | markers = _encodemarkers(repo.obsstore, True) | |
|
250 | return {'dump': base85.b85encode(''.join(markers))} | |
|
258 | keys = {} | |
|
259 | parts = [] | |
|
260 | currentlen = _maxpayload * 2 # ensure we create a new part | |
|
261 | for marker in repo.obsstore: | |
|
262 | nextdata = _encodeonemarker(marker) | |
|
263 | if (len(nextdata) + currentlen > _maxpayload): | |
|
264 | currentpart = [] | |
|
265 | currentlen = 0 | |
|
266 | parts.append(currentpart) | |
|
267 | currentpart.append(nextdata) | |
|
268 | for idx, part in enumerate(reversed(parts)): | |
|
269 | data = ''.join([_pack('>B', _fmversion)] + part) | |
|
270 | keys['dump%i' % idx] = base85.b85encode(data) | |
|
271 | return keys | |
|
251 | 272 | |
|
252 | 273 | def pushmarker(repo, key, old, new): |
|
253 | 274 | """Push markers over pushkey""" |
|
254 |
if key |
|
|
275 | if not key.startswith('dump'): | |
|
255 | 276 | repo.ui.warn(_('unknown key: %r') % key) |
|
256 | 277 | return 0 |
|
257 | 278 | if old: |
General Comments 0
You need to be logged in to leave comments.
Login now