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