Show More
@@ -522,7 +522,7 b' class revisiondelta(object):' | |||
|
522 | 522 | class cgpacker(object): |
|
523 | 523 | def __init__(self, repo, filematcher, version, allowreorder, |
|
524 | 524 | useprevdelta, builddeltaheader, manifestsend, |
|
525 | sendtreemanifests, bundlecaps=None): | |
|
525 | sendtreemanifests, bundlecaps=None, shallow=False): | |
|
526 | 526 | """Given a source repo, construct a bundler. |
|
527 | 527 | |
|
528 | 528 | filematcher is a matcher that matches on files to include in the |
@@ -546,6 +546,9 b' class cgpacker(object):' | |||
|
546 | 546 | capabilities which can be used to build the bundle. While bundlecaps is |
|
547 | 547 | unused in core Mercurial, extensions rely on this feature to communicate |
|
548 | 548 | capabilities to customize the changegroup packer. |
|
549 | ||
|
550 | shallow indicates whether shallow data might be sent. The packer may | |
|
551 | need to pack file contents not introduced by the changes being packed. | |
|
549 | 552 | """ |
|
550 | 553 | assert filematcher |
|
551 | 554 | self._filematcher = filematcher |
@@ -560,6 +563,7 b' class cgpacker(object):' | |||
|
560 | 563 | if bundlecaps is None: |
|
561 | 564 | bundlecaps = set() |
|
562 | 565 | self._bundlecaps = bundlecaps |
|
566 | self._isshallow = shallow | |
|
563 | 567 | |
|
564 | 568 | # experimental config: bundle.reorder |
|
565 | 569 | reorder = repo.ui.config('bundle', 'reorder') |
@@ -736,7 +740,7 b' class cgpacker(object):' | |||
|
736 | 740 | mfrevlog.rev(n)) |
|
737 | 741 | # We can't trust the changed files list in the changeset if the |
|
738 | 742 | # client requested a shallow clone. |
|
739 |
if self._is |
|
|
743 | if self._isshallow: | |
|
740 | 744 | changedfiles.update(mfl[c[0]].read().keys()) |
|
741 | 745 | else: |
|
742 | 746 | changedfiles.update(c[3]) |
@@ -786,7 +790,7 b' class cgpacker(object):' | |||
|
786 | 790 | |
|
787 | 791 | if ellipsesmode: |
|
788 | 792 | mfdicts = None |
|
789 |
if self._is |
|
|
793 | if self._isshallow: | |
|
790 | 794 | mfdicts = [(self._repo.manifestlog[n].read(), lr) |
|
791 | 795 | for (n, lr) in mfs.iteritems()] |
|
792 | 796 | |
@@ -892,7 +896,7 b' class cgpacker(object):' | |||
|
892 | 896 | def generatefiles(self, changedfiles, linknodes, commonrevs, source): |
|
893 | 897 | changedfiles = list(filter(self._filematcher, changedfiles)) |
|
894 | 898 | |
|
895 |
if |
|
|
899 | if self._isshallow: | |
|
896 | 900 | # See comment in generate() for why this sadness is a thing. |
|
897 | 901 | mfdicts = self._mfdicts |
|
898 | 902 | del self._mfdicts |
@@ -1171,7 +1175,7 b' class cgpacker(object):' | |||
|
1171 | 1175 | deltachunks=(diffheader, data), |
|
1172 | 1176 | ) |
|
1173 | 1177 | |
|
1174 | def _makecg1packer(repo, filematcher, bundlecaps): | |
|
1178 | def _makecg1packer(repo, filematcher, bundlecaps, shallow=False): | |
|
1175 | 1179 | builddeltaheader = lambda d: _CHANGEGROUPV1_DELTA_HEADER.pack( |
|
1176 | 1180 | d.node, d.p1node, d.p2node, d.linknode) |
|
1177 | 1181 | |
@@ -1181,9 +1185,10 b' def _makecg1packer(repo, filematcher, bu' | |||
|
1181 | 1185 | builddeltaheader=builddeltaheader, |
|
1182 | 1186 | manifestsend=b'', |
|
1183 | 1187 | sendtreemanifests=False, |
|
1184 |
bundlecaps=bundlecaps |
|
|
1188 | bundlecaps=bundlecaps, | |
|
1189 | shallow=shallow) | |
|
1185 | 1190 | |
|
1186 | def _makecg2packer(repo, filematcher, bundlecaps): | |
|
1191 | def _makecg2packer(repo, filematcher, bundlecaps, shallow=False): | |
|
1187 | 1192 | builddeltaheader = lambda d: _CHANGEGROUPV2_DELTA_HEADER.pack( |
|
1188 | 1193 | d.node, d.p1node, d.p2node, d.basenode, d.linknode) |
|
1189 | 1194 | |
@@ -1196,9 +1201,10 b' def _makecg2packer(repo, filematcher, bu' | |||
|
1196 | 1201 | builddeltaheader=builddeltaheader, |
|
1197 | 1202 | manifestsend=b'', |
|
1198 | 1203 | sendtreemanifests=False, |
|
1199 |
bundlecaps=bundlecaps |
|
|
1204 | bundlecaps=bundlecaps, | |
|
1205 | shallow=shallow) | |
|
1200 | 1206 | |
|
1201 | def _makecg3packer(repo, filematcher, bundlecaps): | |
|
1207 | def _makecg3packer(repo, filematcher, bundlecaps, shallow=False): | |
|
1202 | 1208 | builddeltaheader = lambda d: _CHANGEGROUPV3_DELTA_HEADER.pack( |
|
1203 | 1209 | d.node, d.p1node, d.p2node, d.basenode, d.linknode, d.flags) |
|
1204 | 1210 | |
@@ -1208,7 +1214,8 b' def _makecg3packer(repo, filematcher, bu' | |||
|
1208 | 1214 | builddeltaheader=builddeltaheader, |
|
1209 | 1215 | manifestsend=closechunk(), |
|
1210 | 1216 | sendtreemanifests=True, |
|
1211 |
bundlecaps=bundlecaps |
|
|
1217 | bundlecaps=bundlecaps, | |
|
1218 | shallow=shallow) | |
|
1212 | 1219 | |
|
1213 | 1220 | _packermap = {'01': (_makecg1packer, cg1unpacker), |
|
1214 | 1221 | # cg2 adds support for exchanging generaldelta |
@@ -1268,7 +1275,8 b' def safeversion(repo):' | |||
|
1268 | 1275 | assert versions |
|
1269 | 1276 | return min(versions) |
|
1270 | 1277 | |
|
1271 |
def getbundler(version, repo, bundlecaps=None, filematcher=None |
|
|
1278 | def getbundler(version, repo, bundlecaps=None, filematcher=None, | |
|
1279 | shallow=False): | |
|
1272 | 1280 | assert version in supportedoutgoingversions(repo) |
|
1273 | 1281 | |
|
1274 | 1282 | if filematcher is None: |
@@ -1284,7 +1292,7 b' def getbundler(version, repo, bundlecaps' | |||
|
1284 | 1292 | filematcher) |
|
1285 | 1293 | |
|
1286 | 1294 | fn = _packermap[version][0] |
|
1287 | return fn(repo, filematcher, bundlecaps) | |
|
1295 | return fn(repo, filematcher, bundlecaps, shallow=shallow) | |
|
1288 | 1296 | |
|
1289 | 1297 | def getunbundler(version, fh, alg, extras=None): |
|
1290 | 1298 | return _packermap[version][1](fh, alg, extras=extras) |
@@ -1379,7 +1387,8 b' def _packellipsischangegroup(repo, commo' | |||
|
1379 | 1387 | # set, we know we have an ellipsis node and we should defer |
|
1380 | 1388 | # sending that node's data. We override close() to detect |
|
1381 | 1389 | # pending ellipsis nodes and flush them. |
|
1382 |
packer = getbundler(version, repo, filematcher=match |
|
|
1390 | packer = getbundler(version, repo, filematcher=match, | |
|
1391 | shallow=depth is not None) | |
|
1383 | 1392 | # Give the packer the list of nodes which should not be |
|
1384 | 1393 | # ellipsis nodes. We store this rather than the set of nodes |
|
1385 | 1394 | # that should be an ellipsis because for very large histories |
@@ -1395,8 +1404,5 b' def _packellipsischangegroup(repo, commo' | |||
|
1395 | 1404 | # during changelog stage and then left unmodified. |
|
1396 | 1405 | packer._clnode_to_rev = {} |
|
1397 | 1406 | packer._changelog_done = False |
|
1398 | # If true, informs the packer that it is serving shallow content and might | |
|
1399 | # need to pack file contents not introduced by the changes being packed. | |
|
1400 | packer._is_shallow = depth is not None | |
|
1401 | 1407 | |
|
1402 | 1408 | return packer.generate(common, visitnodes, False, source) |
General Comments 0
You need to be logged in to leave comments.
Login now