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