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