##// END OF EJS Templates
dirstate: move management of the dirstate dirs into the dirstatemap...
Mark Thomas -
r35080:a947cf87 default
parent child Browse files
Show More
@@ -387,9 +387,6 b' class dirstate(object):'
387 387 return self._map.copymap
388 388
389 389 def _droppath(self, f):
390 if self[f] not in "?r" and "dirs" in self._map.__dict__:
391 self._map.dirs.delpath(f)
392
393 390 if "filefoldmap" in self._map.__dict__:
394 391 normed = util.normcase(f)
395 392 if normed in self._map.filefoldmap:
@@ -411,11 +408,9 b' class dirstate(object):'
411 408 if entry is not None and entry[0] != 'r':
412 409 raise error.Abort(
413 410 _('file %r in dirstate clashes with %r') % (d, f))
414 if oldstate in "?r" and "dirs" in self._map.__dict__:
415 self._map.dirs.addpath(f)
416 411 self._dirty = True
417 412 self._updatedfiles.add(f)
418 self._map.addfile(f, state, mode, size, mtime)
413 self._map.addfile(f, oldstate, state, mode, size, mtime)
419 414
420 415 def normal(self, f):
421 416 '''Mark a file normal and clean.'''
@@ -476,6 +471,7 b' class dirstate(object):'
476 471 '''Mark a file removed.'''
477 472 self._dirty = True
478 473 self._droppath(f)
474 oldstate = self[f]
479 475 size = 0
480 476 if self._pl[1] != nullid:
481 477 entry = self._map.get(f)
@@ -486,7 +482,7 b' class dirstate(object):'
486 482 elif entry[0] == 'n' and entry[2] == -2: # other parent
487 483 size = -2
488 484 self._map.otherparentset.add(f)
489 self._map.removefile(f, size)
485 self._map.removefile(f, oldstate, size)
490 486 if size == 0:
491 487 self._map.copymap.pop(f, None)
492 488
@@ -498,7 +494,8 b' class dirstate(object):'
498 494
499 495 def drop(self, f):
500 496 '''Drop a file from the dirstate'''
501 if self._map.dropfile(f):
497 oldstate = self[f]
498 if self._map.dropfile(f, oldstate):
502 499 self._dirty = True
503 500 self._droppath(f)
504 501 self._map.copymap.pop(f, None)
@@ -1217,8 +1214,8 b' class dirstatemap(object):'
1217 1214 - `dirfoldmap` is a dict mapping normalized directory names to the
1218 1215 denormalized form that they appear as in the dirstate.
1219 1216
1220 Once instantiated, the dirs, filefoldmap and dirfoldmap views must be
1221 maintained by the caller.
1217 Once instantiated, the filefoldmap and dirfoldmap views must be maintained
1218 by the caller.
1222 1219 """
1223 1220
1224 1221 def __init__(self, ui, opener, root):
@@ -1280,15 +1277,17 b' class dirstatemap(object):'
1280 1277 """Loads the underlying data, if it's not already loaded"""
1281 1278 self._map
1282 1279
1283 def addfile(self, f, state, mode, size, mtime):
1280 def addfile(self, f, oldstate, state, mode, size, mtime):
1284 1281 """Add a tracked file to the dirstate."""
1282 if oldstate in "?r" and "dirs" in self.__dict__:
1283 self.dirs.addpath(f)
1285 1284 self._map[f] = dirstatetuple(state, mode, size, mtime)
1286 1285 if state != 'n' or mtime == -1:
1287 1286 self.nonnormalset.add(f)
1288 1287 if size == -2:
1289 1288 self.otherparentset.add(f)
1290 1289
1291 def removefile(self, f, size):
1290 def removefile(self, f, oldstate, size):
1292 1291 """
1293 1292 Mark a file as removed in the dirstate.
1294 1293
@@ -1296,15 +1295,20 b' class dirstatemap(object):'
1296 1295 the file's previous state. In the future, we should refactor this
1297 1296 to be more explicit about what that state is.
1298 1297 """
1298 if oldstate not in "?r" and "dirs" in self.__dict__:
1299 self.dirs.delpath(f)
1299 1300 self._map[f] = dirstatetuple('r', 0, size, 0)
1300 1301 self.nonnormalset.add(f)
1301 1302
1302 def dropfile(self, f):
1303 def dropfile(self, f, oldstate):
1303 1304 """
1304 1305 Remove a file from the dirstate. Returns True if the file was
1305 1306 previously recorded.
1306 1307 """
1307 1308 exists = self._map.pop(f, None) is not None
1309 if exists:
1310 if oldstate != "r" and "dirs" in self.__dict__:
1311 self.dirs.delpath(f)
1308 1312 self.nonnormalset.discard(f)
1309 1313 return exists
1310 1314
General Comments 0
You need to be logged in to leave comments. Login now