##// END OF EJS Templates
statichttprepo: use new functions for requirements validation...
Gregory Szorc -
r39730:61929805 default
parent child Browse files
Show More
@@ -1145,25 +1145,6 b' def dirstatecopy(ui, repo, wctx, src, ds'
1145 elif not dryrun:
1145 elif not dryrun:
1146 wctx.copy(origsrc, dst)
1146 wctx.copy(origsrc, dst)
1147
1147
1148 def readrequires(opener, supported):
1149 '''Reads and parses .hg/requires and checks if all entries found
1150 are in the list of supported features.'''
1151 requirements = set(opener.read("requires").splitlines())
1152 missings = []
1153 for r in requirements:
1154 if r not in supported:
1155 if not r or not r[0:1].isalnum():
1156 raise error.RequirementError(_(".hg/requires file is corrupt"))
1157 missings.append(r)
1158 missings.sort()
1159 if missings:
1160 raise error.RequirementError(
1161 _("repository requires features unknown to this Mercurial: %s")
1162 % " ".join(missings),
1163 hint=_("see https://mercurial-scm.org/wiki/MissingRequirement"
1164 " for more information"))
1165 return requirements
1166
1167 def writerequires(opener, requirements):
1148 def writerequires(opener, requirements):
1168 with opener('requires', 'w') as fp:
1149 with opener('requires', 'w') as fp:
1169 for r in sorted(requirements):
1150 for r in sorted(requirements):
@@ -19,7 +19,6 b' from . import ('
19 manifest,
19 manifest,
20 namespaces,
20 namespaces,
21 pathutil,
21 pathutil,
22 scmutil,
23 store,
22 store,
24 url,
23 url,
25 util,
24 util,
@@ -156,7 +155,7 b' class statichttprepository(localrepo.loc'
156 self.filtername = None
155 self.filtername = None
157
156
158 try:
157 try:
159 requirements = scmutil.readrequires(self.vfs, self.supported)
158 requirements = set(self.vfs.read(b'requires').splitlines())
160 except IOError as inst:
159 except IOError as inst:
161 if inst.errno != errno.ENOENT:
160 if inst.errno != errno.ENOENT:
162 raise
161 raise
@@ -174,6 +173,10 b' class statichttprepository(localrepo.loc'
174 msg = _("'%s' does not appear to be an hg repository") % path
173 msg = _("'%s' does not appear to be an hg repository") % path
175 raise error.RepoError(msg)
174 raise error.RepoError(msg)
176
175
176 supportedrequirements = localrepo.gathersupportedrequirements(ui)
177 localrepo.ensurerequirementsrecognized(requirements,
178 supportedrequirements)
179
177 # setup store
180 # setup store
178 self.store = store.store(requirements, self.path, vfsclass)
181 self.store = store.store(requirements, self.path, vfsclass)
179 self.spath = self.store.path
182 self.spath = self.store.path
General Comments 0
You need to be logged in to leave comments. Login now