Show More
@@ -12,6 +12,7 b' import errno, urllib' | |||||
12 | import util, scmutil, changegroup, base85, error, store |
|
12 | import util, scmutil, changegroup, base85, error, store | |
13 | import discovery, phases, obsolete, bookmarks as bookmod, bundle2, pushkey |
|
13 | import discovery, phases, obsolete, bookmarks as bookmod, bundle2, pushkey | |
14 | import lock as lockmod |
|
14 | import lock as lockmod | |
|
15 | import tags | |||
15 |
|
16 | |||
16 | def readbundle(ui, fh, fname, vfs=None): |
|
17 | def readbundle(ui, fh, fname, vfs=None): | |
17 | header = changegroup.readexactly(fh, 4) |
|
18 | header = changegroup.readexactly(fh, 4) | |
@@ -1285,6 +1286,49 b' def _getbundleobsmarkerpart(bundler, rep' | |||||
1285 | markers = sorted(markers) |
|
1286 | markers = sorted(markers) | |
1286 | buildobsmarkerspart(bundler, markers) |
|
1287 | buildobsmarkerspart(bundler, markers) | |
1287 |
|
1288 | |||
|
1289 | @getbundle2partsgenerator('hgtagsfnodes') | |||
|
1290 | def _getbundletagsfnodes(bundler, repo, source, bundlecaps=None, | |||
|
1291 | b2caps=None, heads=None, common=None, | |||
|
1292 | **kwargs): | |||
|
1293 | """Transfer the .hgtags filenodes mapping. | |||
|
1294 | ||||
|
1295 | Only values for heads in this bundle will be transferred. | |||
|
1296 | ||||
|
1297 | The part data consists of pairs of 20 byte changeset node and .hgtags | |||
|
1298 | filenodes raw values. | |||
|
1299 | """ | |||
|
1300 | # Don't send unless: | |||
|
1301 | # - changeset are being exchanged, | |||
|
1302 | # - the client supports it. | |||
|
1303 | if not (kwargs.get('cg', True) and 'hgtagsfnodes' in b2caps): | |||
|
1304 | return | |||
|
1305 | ||||
|
1306 | outgoing = changegroup.computeoutgoing(repo, heads, common) | |||
|
1307 | ||||
|
1308 | if not outgoing.missingheads: | |||
|
1309 | return | |||
|
1310 | ||||
|
1311 | cache = tags.hgtagsfnodescache(repo.unfiltered()) | |||
|
1312 | chunks = [] | |||
|
1313 | ||||
|
1314 | # .hgtags fnodes are only relevant for head changesets. While we could | |||
|
1315 | # transfer values for all known nodes, there will likely be little to | |||
|
1316 | # no benefit. | |||
|
1317 | # | |||
|
1318 | # We don't bother using a generator to produce output data because | |||
|
1319 | # a) we only have 40 bytes per head and even esoteric numbers of heads | |||
|
1320 | # consume little memory (1M heads is 40MB) b) we don't want to send the | |||
|
1321 | # part if we don't have entries and knowing if we have entries requires | |||
|
1322 | # cache lookups. | |||
|
1323 | for node in outgoing.missingheads: | |||
|
1324 | # Don't compute missing, as this may slow down serving. | |||
|
1325 | fnode = cache.getfnode(node, computemissing=False) | |||
|
1326 | if fnode is not None: | |||
|
1327 | chunks.extend([node, fnode]) | |||
|
1328 | ||||
|
1329 | if chunks: | |||
|
1330 | bundler.newpart('hgtagsfnodes', data=''.join(chunks)) | |||
|
1331 | ||||
1288 | def check_heads(repo, their_heads, context): |
|
1332 | def check_heads(repo, their_heads, context): | |
1289 | """check if the heads of a repo have been modified |
|
1333 | """check if the heads of a repo have been modified | |
1290 |
|
1334 |
@@ -625,3 +625,77 b' Test for issue3911' | |||||
625 | globaltag 0:bbd179dfa0a7 |
|
625 | globaltag 0:bbd179dfa0a7 | |
626 |
|
626 | |||
627 | $ cd .. |
|
627 | $ cd .. | |
|
628 | ||||
|
629 | Create a repository with tags data to test .hgtags fnodes transfer | |||
|
630 | ||||
|
631 | $ hg init tagsserver | |||
|
632 | $ cd tagsserver | |||
|
633 | $ cat > .hg/hgrc << EOF | |||
|
634 | > [experimental] | |||
|
635 | > bundle2-exp=True | |||
|
636 | > EOF | |||
|
637 | $ touch foo | |||
|
638 | $ hg -q commit -A -m initial | |||
|
639 | $ hg tag -m 'tag 0.1' 0.1 | |||
|
640 | $ echo second > foo | |||
|
641 | $ hg commit -m second | |||
|
642 | $ hg tag -m 'tag 0.2' 0.2 | |||
|
643 | $ hg tags | |||
|
644 | tip 3:40f0358cb314 | |||
|
645 | 0.2 2:f63cc8fe54e4 | |||
|
646 | 0.1 0:96ee1d7354c4 | |||
|
647 | $ cd .. | |||
|
648 | ||||
|
649 | Cloning should pull down hgtags fnodes mappings and write the cache file | |||
|
650 | ||||
|
651 | $ hg --config experimental.bundle2-exp=True clone --pull tagsserver tagsclient | |||
|
652 | requesting all changes | |||
|
653 | adding changesets | |||
|
654 | adding manifests | |||
|
655 | adding file changes | |||
|
656 | added 4 changesets with 4 changes to 2 files | |||
|
657 | updating to branch default | |||
|
658 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
659 | ||||
|
660 | Missing tags2* files means the cache wasn't written through the normal mechanism. | |||
|
661 | ||||
|
662 | $ ls tagsclient/.hg/cache | |||
|
663 | branch2-served | |||
|
664 | hgtagsfnodes1 | |||
|
665 | rbc-names-v1 | |||
|
666 | rbc-revs-v1 | |||
|
667 | ||||
|
668 | Cache should contain the head only, even though other nodes have tags data | |||
|
669 | ||||
|
670 | $ f --size --hexdump tagsclient/.hg/cache/hgtagsfnodes1 | |||
|
671 | tagsclient/.hg/cache/hgtagsfnodes1: size=96 | |||
|
672 | 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| | |||
|
673 | 0010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| | |||
|
674 | 0020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| | |||
|
675 | 0030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| | |||
|
676 | 0040: ff ff ff ff ff ff ff ff 40 f0 35 8c 19 e0 a7 d3 |........@.5.....| | |||
|
677 | 0050: 8a 5c 6a 82 4d cf fb a5 87 d0 2f a3 1e 4f 2f 8a |.\j.M...../..O/.| | |||
|
678 | ||||
|
679 | Running hg tags should produce tags2* file and not change cache | |||
|
680 | ||||
|
681 | $ hg -R tagsclient tags | |||
|
682 | tip 3:40f0358cb314 | |||
|
683 | 0.2 2:f63cc8fe54e4 | |||
|
684 | 0.1 0:96ee1d7354c4 | |||
|
685 | ||||
|
686 | $ ls tagsclient/.hg/cache | |||
|
687 | branch2-served | |||
|
688 | hgtagsfnodes1 | |||
|
689 | rbc-names-v1 | |||
|
690 | rbc-revs-v1 | |||
|
691 | tags2-visible | |||
|
692 | ||||
|
693 | $ f --size --hexdump tagsclient/.hg/cache/hgtagsfnodes1 | |||
|
694 | tagsclient/.hg/cache/hgtagsfnodes1: size=96 | |||
|
695 | 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| | |||
|
696 | 0010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| | |||
|
697 | 0020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| | |||
|
698 | 0030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| | |||
|
699 | 0040: ff ff ff ff ff ff ff ff 40 f0 35 8c 19 e0 a7 d3 |........@.5.....| | |||
|
700 | 0050: 8a 5c 6a 82 4d cf fb a5 87 d0 2f a3 1e 4f 2f 8a |.\j.M...../..O/.| | |||
|
701 |
General Comments 0
You need to be logged in to leave comments.
Login now