# HG changeset patch # User Matt Mackall # Date 1182191074 18000 # Node ID 70352337934e0ef9c0010d659ff8bab62331f4e3 # Parent 9b00b73a528697387869f950dea39004e1aaf3fc dirstate: refactor checkinterfering diff -r 9b00b73a5286 -r 70352337934e mercurial/dirstate.py --- a/mercurial/dirstate.py Mon Jun 18 13:24:34 2007 -0500 +++ b/mercurial/dirstate.py Mon Jun 18 13:24:34 2007 -0500 @@ -182,26 +182,19 @@ self._dirs.setdefault(pc, 0) self._dirs[pc] -= 1 - def checkinterfering(self, files): - def prefixes(f): - for c in strutil.rfindall(f, '/'): - yield f[:c] - seendirs = {} - for f in files: - # shadows - if self._dirs.get(f): - raise util.Abort(_('directory named %r already in dirstate') % - f) - for d in prefixes(f): - if d in seendirs: - break - if d in self._map: - raise util.Abort(_('file named %r already in dirstate') % - d) - seendirs[d] = True - # disallowed - if '\r' in f or '\n' in f: - raise util.Abort(_("'\\n' and '\\r' disallowed in filenames")) + def _incpathcheck(self, f): + if '\r' in f or '\n' in f: + raise util.Abort(_("'\\n' and '\\r' disallowed in filenames")) + # shadows + if f in self._dirs: + raise util.Abort(_('directory named %r already in dirstate') % f) + for c in strutil.rfindall(f, '/'): + d = f[:c] + if d in self._dirs: + break + if d in self._map: + raise util.Abort(_('file named %r already in dirstate') % d) + self._incpath(f) def update(self, files, state, **kw): ''' current states: @@ -212,21 +205,21 @@ if not files: return self.markdirty() - if state == "a": - self.checkinterfering(files) for f in files: + if self._copymap.has_key(f): + del self._copymap[f] + if state == "r": self._map[f] = ('r', 0, 0, 0) self._decpath(f) + continue else: if state == "a": - self._incpath(f) + self._incpathcheck(f) s = os.lstat(self.wjoin(f)) st_size = kw.get('st_size', s.st_size) st_mtime = kw.get('st_mtime', s.st_mtime) self._map[f] = (state, s.st_mode, st_size, st_mtime) - if self._copymap.has_key(f): - del self._copymap[f] def forget(self, files): if not files: return