comparison mercurial/dirstate.py @ 5483:0c43f87baba3 default tip

Fix file-changed-to-dir and dir-to-file commits (issue660). Allow adding to dirstate files that clash with previously existing but marked for removal. Protect from reintroducing clashes by revert. This change doesn't address related issues with update. Current workaround is to do "clean" update by manually removing conflicting files/dirs from working directory.
author Maxim Dounin <mdounin@mdounin.ru>
date Sat, 27 Oct 2007 16:27:55 +0400
parents 5105b119edd2
children
comparison
equal deleted inserted replaced
5482:7ceb740f2fef 5483:0c43f87baba3
48 if err.errno != errno.ENOENT: raise 48 if err.errno != errno.ENOENT: raise
49 return self._pl 49 return self._pl
50 elif name == '_dirs': 50 elif name == '_dirs':
51 self._dirs = {} 51 self._dirs = {}
52 for f in self._map: 52 for f in self._map:
53 self._incpath(f) 53 if self[f] != 'r':
54 self._incpath(f)
54 return self._dirs 55 return self._dirs
55 elif name == '_ignore': 56 elif name == '_ignore':
56 files = [self._join('.hgignore')] 57 files = [self._join('.hgignore')]
57 for name, path in self._ui.configitems("ui"): 58 for name, path in self._ui.configitems("ui"):
58 if name == 'ignore' or name.startswith('ignore.'): 59 if name == 'ignore' or name.startswith('ignore.'):
203 raise util.Abort(_('directory %r already in dirstate') % f) 204 raise util.Abort(_('directory %r already in dirstate') % f)
204 for c in strutil.rfindall(f, '/'): 205 for c in strutil.rfindall(f, '/'):
205 d = f[:c] 206 d = f[:c]
206 if d in self._dirs: 207 if d in self._dirs:
207 break 208 break
208 if d in self._map: 209 if d in self._map and self[d] != 'r':
209 raise util.Abort(_('file %r in dirstate clashes with %r') % 210 raise util.Abort(_('file %r in dirstate clashes with %r') %
210 (d, f)) 211 (d, f))
211 self._incpath(f) 212 self._incpath(f)
212 213
213 def normal(self, f): 214 def normal(self, f):
214 'mark a file normal and clean' 215 'mark a file normal and clean'
215 self._dirty = True 216 self._dirty = True
217 if self[f] == 'r':
218 self._incpathcheck(f)
216 s = os.lstat(self._join(f)) 219 s = os.lstat(self._join(f))
217 self._map[f] = ('n', s.st_mode, s.st_size, s.st_mtime, 0) 220 self._map[f] = ('n', s.st_mode, s.st_size, s.st_mtime, 0)
218 if self._copymap.has_key(f): 221 if self._copymap.has_key(f):
219 del self._copymap[f] 222 del self._copymap[f]
220 223
221 def normallookup(self, f): 224 def normallookup(self, f):
222 'mark a file normal, but possibly dirty' 225 'mark a file normal, but possibly dirty'
223 self._dirty = True 226 self._dirty = True
227 if self[f] == 'r':
228 self._incpathcheck(f)
224 self._map[f] = ('n', 0, -1, -1, 0) 229 self._map[f] = ('n', 0, -1, -1, 0)
225 if f in self._copymap: 230 if f in self._copymap:
226 del self._copymap[f] 231 del self._copymap[f]
227 232
228 def normaldirty(self, f): 233 def normaldirty(self, f):
229 'mark a file normal, but dirty' 234 'mark a file normal, but dirty'
230 self._dirty = True 235 self._dirty = True
236 if self[f] == 'r':
237 self._incpathcheck(f)
231 self._map[f] = ('n', 0, -2, -1, 0) 238 self._map[f] = ('n', 0, -2, -1, 0)
232 if f in self._copymap: 239 if f in self._copymap:
233 del self._copymap[f] 240 del self._copymap[f]
234 241
235 def add(self, f): 242 def add(self, f):
258 265
259 def forget(self, f): 266 def forget(self, f):
260 'forget a file' 267 'forget a file'
261 self._dirty = True 268 self._dirty = True
262 try: 269 try:
270 if self[f] != 'r':
271 self._decpath(f)
263 del self._map[f] 272 del self._map[f]
264 self._decpath(f)
265 except KeyError: 273 except KeyError:
266 self._ui.warn(_("not in dirstate: %s!\n") % f) 274 self._ui.warn(_("not in dirstate: %s!\n") % f)
267 275
268 def clear(self): 276 def clear(self):
269 self._map = {} 277 self._map = {}
520 nonexistent = True 528 nonexistent = True
521 if not st: 529 if not st:
522 try: 530 try:
523 st = lstat(_join(fn)) 531 st = lstat(_join(fn))
524 except OSError, inst: 532 except OSError, inst:
525 if inst.errno != errno.ENOENT: 533 if inst.errno not in (errno.ENOENT, errno.ENOTDIR):
526 raise 534 raise
527 st = None 535 st = None
528 # We need to re-check that it is a valid file 536 # We need to re-check that it is a valid file
529 if st and self._supported(fn, st.st_mode): 537 if st and self._supported(fn, st.st_mode):
530 nonexistent = False 538 nonexistent = False