##// END OF EJS Templates
dirstate: factor common update code into _addpath...
Joshua Redstone -
r17094:c2016bae default
parent child Browse files
Show More
@@ -312,7 +312,8 b' class dirstate(object):'
312 if self[f] not in "?r" and "_dirs" in self.__dict__:
312 if self[f] not in "?r" and "_dirs" in self.__dict__:
313 _decdirs(self._dirs, f)
313 _decdirs(self._dirs, f)
314
314
315 def _addpath(self, f, check=False):
315 def _addpath(self, f, state, mode, size, mtime, check=False):
316 assert state not in "?r"
316 oldstate = self[f]
317 oldstate = self[f]
317 if check or oldstate == "r":
318 if check or oldstate == "r":
318 scmutil.checkfilename(f)
319 scmutil.checkfilename(f)
@@ -327,14 +328,14 b' class dirstate(object):'
327 _('file %r in dirstate clashes with %r') % (d, f))
328 _('file %r in dirstate clashes with %r') % (d, f))
328 if oldstate in "?r" and "_dirs" in self.__dict__:
329 if oldstate in "?r" and "_dirs" in self.__dict__:
329 _incdirs(self._dirs, f)
330 _incdirs(self._dirs, f)
331 self._dirty = True
332 self._map[f] = (state, mode, size, mtime)
330
333
331 def normal(self, f):
334 def normal(self, f):
332 '''Mark a file normal and clean.'''
335 '''Mark a file normal and clean.'''
333 self._dirty = True
334 self._addpath(f)
335 s = os.lstat(self._join(f))
336 s = os.lstat(self._join(f))
336 mtime = int(s.st_mtime)
337 mtime = int(s.st_mtime)
337 self._map[f] = ('n', s.st_mode, s.st_size, mtime)
338 self._addpath(f, 'n', s.st_mode, s.st_size, mtime)
338 if f in self._copymap:
339 if f in self._copymap:
339 del self._copymap[f]
340 del self._copymap[f]
340 if mtime > self._lastnormaltime:
341 if mtime > self._lastnormaltime:
@@ -361,9 +362,7 b' class dirstate(object):'
361 return
362 return
362 if entry[0] == 'm' or entry[0] == 'n' and entry[2] == -2:
363 if entry[0] == 'm' or entry[0] == 'n' and entry[2] == -2:
363 return
364 return
364 self._dirty = True
365 self._addpath(f, 'n', 0, -1, -1)
365 self._addpath(f)
366 self._map[f] = ('n', 0, -1, -1)
367 if f in self._copymap:
366 if f in self._copymap:
368 del self._copymap[f]
367 del self._copymap[f]
369
368
@@ -372,17 +371,13 b' class dirstate(object):'
372 if self._pl[1] == nullid:
371 if self._pl[1] == nullid:
373 raise util.Abort(_("setting %r to other parent "
372 raise util.Abort(_("setting %r to other parent "
374 "only allowed in merges") % f)
373 "only allowed in merges") % f)
375 self._dirty = True
374 self._addpath(f, 'n', 0, -2, -1)
376 self._addpath(f)
377 self._map[f] = ('n', 0, -2, -1)
378 if f in self._copymap:
375 if f in self._copymap:
379 del self._copymap[f]
376 del self._copymap[f]
380
377
381 def add(self, f):
378 def add(self, f):
382 '''Mark a file added.'''
379 '''Mark a file added.'''
383 self._dirty = True
380 self._addpath(f, 'a', 0, -1, -1, True)
384 self._addpath(f, True)
385 self._map[f] = ('a', 0, -1, -1)
386 if f in self._copymap:
381 if f in self._copymap:
387 del self._copymap[f]
382 del self._copymap[f]
388
383
@@ -406,10 +401,8 b' class dirstate(object):'
406 '''Mark a file merged.'''
401 '''Mark a file merged.'''
407 if self._pl[1] == nullid:
402 if self._pl[1] == nullid:
408 return self.normallookup(f)
403 return self.normallookup(f)
409 self._dirty = True
410 s = os.lstat(self._join(f))
404 s = os.lstat(self._join(f))
411 self._addpath(f)
405 self._addpath(f, 'm', s.st_mode, s.st_size, int(s.st_mtime))
412 self._map[f] = ('m', s.st_mode, s.st_size, int(s.st_mtime))
413 if f in self._copymap:
406 if f in self._copymap:
414 del self._copymap[f]
407 del self._copymap[f]
415
408
General Comments 0
You need to be logged in to leave comments. Login now