comparison mercurial/bundle2.py @ 25401:d29201352af7

bundle2: part handler for processing .hgtags fnodes mappings .hgtags fnodes cache entries can be expensive to compute, especially if there are hundreds of even thousands of them. This patch implements support for receiving a bundle2 part that contains a mapping of changeset to .hgtags fnodes. An upcoming patch will teach the server to send this part, allowing clients to bypass having to redundantly compute these values. A number of tests changed due to the client advertising the "hgtagsfnodes" capability.
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 01 Jun 2015 20:23:22 -0700
parents 7c60a42265fb
children 6de96cb31176
comparison
equal deleted inserted replaced
25400:7759dc97c5c7 25401:d29201352af7
154 import obsolete 154 import obsolete
155 import pushkey 155 import pushkey
156 import url 156 import url
157 import re 157 import re
158 158
159 import changegroup, error 159 import changegroup, error, tags
160 from i18n import _ 160 from i18n import _
161 161
162 _pack = struct.pack 162 _pack = struct.pack
163 _unpack = struct.unpack 163 _unpack = struct.unpack
164 164
1108 capabilities = {'HG20': (), 1108 capabilities = {'HG20': (),
1109 'listkeys': (), 1109 'listkeys': (),
1110 'pushkey': (), 1110 'pushkey': (),
1111 'digests': tuple(sorted(util.DIGESTS.keys())), 1111 'digests': tuple(sorted(util.DIGESTS.keys())),
1112 'remote-changegroup': ('http', 'https'), 1112 'remote-changegroup': ('http', 'https'),
1113 'hgtagsfnodes': (),
1113 } 1114 }
1114 1115
1115 def getrepocaps(repo, allowpushback=False): 1116 def getrepocaps(repo, allowpushback=False):
1116 """return the bundle2 capabilities for a given repo 1117 """return the bundle2 capabilities for a given repo
1117 1118
1358 def handlepushkeyreply(op, inpart): 1359 def handlepushkeyreply(op, inpart):
1359 """retrieve the result of a pushkey request""" 1360 """retrieve the result of a pushkey request"""
1360 ret = int(inpart.params['new']) 1361 ret = int(inpart.params['new'])
1361 partid = int(inpart.params['in-reply-to']) 1362 partid = int(inpart.params['in-reply-to'])
1362 op.records.add('obsmarkers', {'new': ret}, partid) 1363 op.records.add('obsmarkers', {'new': ret}, partid)
1364
1365 @parthandler('hgtagsfnodes')
1366 def handlehgtagsfnodes(op, inpart):
1367 """Applies .hgtags fnodes cache entries to the local repo.
1368
1369 Payload is pairs of 20 byte changeset nodes and filenodes.
1370 """
1371 cache = tags.hgtagsfnodescache(op.repo.unfiltered())
1372
1373 count = 0
1374 while True:
1375 node = inpart.read(20)
1376 fnode = inpart.read(20)
1377 if len(node) < 20 or len(fnode) < 20:
1378 op.ui.debug('received incomplete .hgtags fnodes data, ignoring\n')
1379 break
1380 cache.setfnode(node, fnode)
1381 count += 1
1382
1383 cache.write()
1384 op.ui.debug('applied %i hgtags fnodes cache entries\n' % count)