##// END OF EJS Templates
narrow: use featuresetupfuncs...
Gregory Szorc -
r37154:e2d386b8 default
parent child Browse files
Show More
@@ -1,95 +1,97 b''
1 1 # __init__.py - narrowhg extension
2 2 #
3 3 # Copyright 2017 Google, Inc.
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7 '''create clones which fetch history data for subset of files (EXPERIMENTAL)'''
8 8
9 9 from __future__ import absolute_import
10 10
11 11 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
12 12 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
13 13 # be specifying the version(s) of Mercurial they are tested with, or
14 14 # leave the attribute unspecified.
15 15 testedwith = 'ships-with-hg-core'
16 16
17 17 from mercurial import (
18 18 changegroup,
19 19 extensions,
20 20 hg,
21 21 localrepo,
22 22 registrar,
23 23 verify as verifymod,
24 24 )
25 25
26 26 from . import (
27 27 narrowbundle2,
28 28 narrowchangegroup,
29 29 narrowcommands,
30 30 narrowcopies,
31 31 narrowdirstate,
32 32 narrowmerge,
33 33 narrowpatch,
34 34 narrowrepo,
35 35 narrowrevlog,
36 36 narrowtemplates,
37 37 narrowwirepeer,
38 38 )
39 39
40 40 configtable = {}
41 41 configitem = registrar.configitem(configtable)
42 42 # Narrowhg *has* support for serving ellipsis nodes (which are used at
43 43 # least by Google's internal server), but that support is pretty
44 44 # fragile and has a lot of problems on real-world repositories that
45 45 # have complex graph topologies. This could probably be corrected, but
46 46 # absent someone needing the full support for ellipsis nodes in
47 47 # repositories with merges, it's unlikely this work will get done. As
48 48 # of this writining in late 2017, all repositories large enough for
49 49 # ellipsis nodes to be a hard requirement also enforce strictly linear
50 50 # history for other scaling reasons.
51 51 configitem('experimental', 'narrowservebrokenellipses',
52 52 default=False,
53 53 alias=[('narrow', 'serveellipses')],
54 54 )
55 55
56 56 # Export the commands table for Mercurial to see.
57 57 cmdtable = narrowcommands.table
58 58
59 localrepo.localrepository._basesupported.add(changegroup.NARROW_REQUIREMENT)
59 def featuresetup(ui, features):
60 features.add(changegroup.NARROW_REQUIREMENT)
60 61
61 62 def uisetup(ui):
62 63 """Wraps user-facing mercurial commands with narrow-aware versions."""
64 localrepo.featuresetupfuncs.add(featuresetup)
63 65 narrowrevlog.setup()
64 66 narrowbundle2.setup()
65 67 narrowmerge.setup()
66 68 narrowcommands.setup()
67 69 narrowchangegroup.setup()
68 70 narrowwirepeer.uisetup()
69 71
70 72 def reposetup(ui, repo):
71 73 """Wraps local repositories with narrow repo support."""
72 74 if not isinstance(repo, localrepo.localrepository):
73 75 return
74 76
75 77 narrowrepo.wraprepo(repo)
76 78 if changegroup.NARROW_REQUIREMENT in repo.requirements:
77 79 narrowcopies.setup(repo)
78 80 narrowdirstate.setup(repo)
79 81 narrowpatch.setup(repo)
80 82 narrowwirepeer.reposetup(repo)
81 83
82 84 def _verifierinit(orig, self, repo, matcher=None):
83 85 # The verifier's matcher argument was desgined for narrowhg, so it should
84 86 # be None from core. If another extension passes a matcher (unlikely),
85 87 # we'll have to fail until matchers can be composed more easily.
86 88 assert matcher is None
87 89 orig(self, repo, repo.narrowmatch())
88 90
89 91 def extsetup(ui):
90 92 extensions.wrapfunction(verifymod.verifier, '__init__', _verifierinit)
91 93 extensions.wrapfunction(hg, 'postshare', narrowrepo.wrappostshare)
92 94 extensions.wrapfunction(hg, 'copystore', narrowrepo.unsharenarrowspec)
93 95
94 96 templatekeyword = narrowtemplates.templatekeyword
95 97 revsetpredicate = narrowtemplates.revsetpredicate
General Comments 0
You need to be logged in to leave comments. Login now