##// END OF EJS Templates
localrepo: make supported features manageable in each repositories individually...
FUJIWARA Katsunori -
r19778:55ef7903 default
parent child Browse files
Show More
@@ -153,7 +153,7 b' def uisetup(ui):'
153 153 httppeer.httppeer._callstream = proto.httprepocallstream
154 154
155 155 # don't die on seeing a repo with the largefiles requirement
156 localrepo.localrepository.supported |= set(['largefiles'])
156 localrepo.localrepository._basesupported |= set(['largefiles'])
157 157
158 158 # override some extensions' stuff as well
159 159 for name, module in extensions.extensions():
@@ -146,12 +146,14 b' class locallegacypeer(localpeer):'
146 146 class localrepository(object):
147 147
148 148 supportedformats = set(('revlogv1', 'generaldelta'))
149 supported = supportedformats | set(('store', 'fncache', 'shared',
149 _basesupported = supportedformats | set(('store', 'fncache', 'shared',
150 150 'dotencode'))
151 151 openerreqs = set(('revlogv1', 'generaldelta'))
152 152 requirements = ['revlogv1']
153 153 filtername = None
154 154
155 featuresetupfuncs = set()
156
155 157 def _baserequirements(self, create):
156 158 return self.requirements[:]
157 159
@@ -176,6 +178,13 b' class localrepository(object):'
176 178 except IOError:
177 179 pass
178 180
181 if self.featuresetupfuncs:
182 self.supported = set(self._basesupported) # use private copy
183 for setupfunc in self.featuresetupfuncs:
184 setupfunc(self.ui, self.supported)
185 else:
186 self.supported = self._basesupported
187
179 188 if not self.vfs.isdir():
180 189 if create:
181 190 if not self.wvfs.exists():
@@ -1649,6 +1658,14 b' class localrepository(object):'
1649 1658 return r
1650 1659
1651 1660 def pull(self, remote, heads=None, force=False):
1661 if remote.local():
1662 missing = set(remote.requirements) - self.supported
1663 if missing:
1664 msg = _("required features are not"
1665 " supported in the destination:"
1666 " %s") % (', '.join(sorted(missing)))
1667 raise util.Abort(msg)
1668
1652 1669 # don't open transaction for nothing or you break future useful
1653 1670 # rollback call
1654 1671 tr = None
@@ -1749,6 +1766,14 b' class localrepository(object):'
1749 1766 we have outgoing changesets but refused to push
1750 1767 - other values as described by addchangegroup()
1751 1768 '''
1769 if remote.local():
1770 missing = set(self.requirements) - remote.local().supported
1771 if missing:
1772 msg = _("required features are not"
1773 " supported in the destination:"
1774 " %s") % (', '.join(sorted(missing)))
1775 raise util.Abort(msg)
1776
1752 1777 # there are two ways to push to remote repo:
1753 1778 #
1754 1779 # addchangegroup assumes local user can lock remote
@@ -89,6 +89,8 b' class statichttppeer(localrepo.localpeer'
89 89 return False
90 90
91 91 class statichttprepository(localrepo.localrepository):
92 supported = localrepo.localrepository._basesupported
93
92 94 def __init__(self, ui, path):
93 95 self._url = path
94 96 self.ui = ui
@@ -15,5 +15,55 b''
15 15 $ hg tip
16 16 abort: unknown repository format: requires features 'indoor-pool', 'outdoor-pool' (upgrade Mercurial)!
17 17 [255]
18 $ cd ..
19
20 Test checking between features supported locally and ones required in
21 another repository of push/pull/clone on localhost:
22
23 $ mkdir supported-locally
24 $ cd supported-locally
25
26 $ hg init supported
27 $ echo a > supported/a
28 $ hg -R supported commit -Am '#0 at supported'
29 adding a
30
31 $ echo 'featuresetup-test' >> supported/.hg/requires
32 $ cat > $TESTTMP/supported-locally/supportlocally.py <<EOF
33 > from mercurial import localrepo, extensions
34 > def featuresetup(ui, supported):
35 > for name, module in extensions.extensions(ui):
36 > if __name__ == module.__name__:
37 > # support specific feature locally
38 > supported |= set(['featuresetup-test'])
39 > return
40 > def uisetup(ui):
41 > localrepo.localrepository.featuresetupfuncs.add(featuresetup)
42 > EOF
43 $ cat > supported/.hg/hgrc <<EOF
44 > [extensions]
45 > # enable extension locally
46 > supportlocally = $TESTTMP/supported-locally/supportlocally.py
47 > EOF
48 $ hg -R supported status
49
50 $ hg init push-dst
51 $ hg -R supported push push-dst
52 pushing to push-dst
53 abort: required features are not supported in the destination: featuresetup-test
54 [255]
55
56 $ hg init pull-src
57 $ hg -R pull-src pull supported
58 pulling from supported
59 abort: required features are not supported in the destination: featuresetup-test
60 [255]
61
62 $ hg clone supported clone-dst
63 abort: unknown repository format: requires features 'featuresetup-test' (upgrade Mercurial)!
64 [255]
65 $ hg clone --pull supported clone-dst
66 abort: required features are not supported in the destination: featuresetup-test
67 [255]
18 68
19 69 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now