##// END OF EJS Templates
introduce new function scmutil.readrequires...
Adrian Buehlmann -
r14482:58b36e9e default
parent child Browse files
Show More
@@ -68,16 +68,12 b' class localrepository(repo.repository):'
68 68 elif create:
69 69 raise error.RepoError(_("repository %s already exists") % path)
70 70 else:
71 # find requirements
72 requirements = set()
73 71 try:
74 requirements = set(self.opener.read("requires").splitlines())
72 requirements = scmutil.readrequires(self.opener, self.supported)
75 73 except IOError, inst:
76 74 if inst.errno != errno.ENOENT:
77 75 raise
78 for r in requirements - self.supported:
79 raise error.RequirementError(
80 _("requirement '%s' not supported") % r)
76 requirements = set()
81 77
82 78 self.sharedpath = self.path
83 79 try:
@@ -691,3 +691,13 b' def dirstatecopy(ui, repo, wctx, src, ds'
691 691 wctx.add([dst])
692 692 elif not dryrun:
693 693 wctx.copy(origsrc, dst)
694
695 def readrequires(opener, supported):
696 '''Reads and parses .hg/requires and checks if all entries found
697 are in the list of supported features.'''
698 requirements = set(opener.read("requires").splitlines())
699 for r in requirements:
700 if r not in supported:
701 raise error.RequirementError(
702 _("requirement '%s' not supported") % r)
703 return requirements
@@ -91,12 +91,13 b' class statichttprepository(localrepo.loc'
91 91 opener = build_opener(ui, authinfo)
92 92 self.opener = opener(self.path)
93 93
94 # find requirements
95 94 try:
96 requirements = self.opener.read("requires").splitlines()
95 requirements = scmutil.readrequires(self.opener, self.supported)
97 96 except IOError, inst:
98 97 if inst.errno != errno.ENOENT:
99 98 raise
99 requirements = set()
100
100 101 # check if it is a non-empty old-style repository
101 102 try:
102 103 fp = self.opener("00changelog.i")
@@ -108,13 +109,6 b' class statichttprepository(localrepo.loc'
108 109 # we do not care about empty old-style repositories here
109 110 msg = _("'%s' does not appear to be an hg repository") % path
110 111 raise error.RepoError(msg)
111 requirements = []
112
113 # check them
114 for r in requirements:
115 if r not in self.supported:
116 raise error.RequirementError(
117 _("requirement '%s' not supported") % r)
118 112
119 113 # setup store
120 114 self.store = store.store(requirements, self.path, opener)
General Comments 0
You need to be logged in to leave comments. Login now