##// END OF EJS Templates
dirstate: refactor checkinterfering
Matt Mackall -
r4616:70352337 default
parent child Browse files
Show More
@@ -182,26 +182,19 b' class dirstate(object):'
182 182 self._dirs.setdefault(pc, 0)
183 183 self._dirs[pc] -= 1
184 184
185 def checkinterfering(self, files):
186 def prefixes(f):
187 for c in strutil.rfindall(f, '/'):
188 yield f[:c]
189 seendirs = {}
190 for f in files:
191 # shadows
192 if self._dirs.get(f):
193 raise util.Abort(_('directory named %r already in dirstate') %
194 f)
195 for d in prefixes(f):
196 if d in seendirs:
197 break
198 if d in self._map:
199 raise util.Abort(_('file named %r already in dirstate') %
200 d)
201 seendirs[d] = True
202 # disallowed
203 if '\r' in f or '\n' in f:
204 raise util.Abort(_("'\\n' and '\\r' disallowed in filenames"))
185 def _incpathcheck(self, f):
186 if '\r' in f or '\n' in f:
187 raise util.Abort(_("'\\n' and '\\r' disallowed in filenames"))
188 # shadows
189 if f in self._dirs:
190 raise util.Abort(_('directory named %r already in dirstate') % f)
191 for c in strutil.rfindall(f, '/'):
192 d = f[:c]
193 if d in self._dirs:
194 break
195 if d in self._map:
196 raise util.Abort(_('file named %r already in dirstate') % d)
197 self._incpath(f)
205 198
206 199 def update(self, files, state, **kw):
207 200 ''' current states:
@@ -212,21 +205,21 b' class dirstate(object):'
212 205
213 206 if not files: return
214 207 self.markdirty()
215 if state == "a":
216 self.checkinterfering(files)
217 208 for f in files:
209 if self._copymap.has_key(f):
210 del self._copymap[f]
211
218 212 if state == "r":
219 213 self._map[f] = ('r', 0, 0, 0)
220 214 self._decpath(f)
215 continue
221 216 else:
222 217 if state == "a":
223 self._incpath(f)
218 self._incpathcheck(f)
224 219 s = os.lstat(self.wjoin(f))
225 220 st_size = kw.get('st_size', s.st_size)
226 221 st_mtime = kw.get('st_mtime', s.st_mtime)
227 222 self._map[f] = (state, s.st_mode, st_size, st_mtime)
228 if self._copymap.has_key(f):
229 del self._copymap[f]
230 223
231 224 def forget(self, files):
232 225 if not files: return
General Comments 0
You need to be logged in to leave comments. Login now