##// END OF EJS Templates
dirstate: move opendirstatefile to dirstatemap...
Durham Goode -
r34338:c36c3fa7 default
parent child Browse files
Show More
@@ -82,9 +82,6 b' class dirstate(object):'
82 82 self._origpl = None
83 83 self._updatedfiles = set()
84 84
85 # for consistent view between _pl() and _read() invocations
86 self._pendingmode = None
87
88 85 @contextlib.contextmanager
89 86 def parentchange(self):
90 87 '''Context manager for handling dirstate parents.
@@ -190,7 +187,7 b' class dirstate(object):'
190 187 @propertycache
191 188 def _pl(self):
192 189 try:
193 fp = self._opendirstatefile()
190 fp = self._map._opendirstatefile()
194 191 st = fp.read(40)
195 192 fp.close()
196 193 l = len(st)
@@ -401,23 +398,14 b' class dirstate(object):'
401 398 f.discard()
402 399 raise
403 400
404 def _opendirstatefile(self):
405 fp, mode = txnutil.trypending(self._root, self._opener, self._filename)
406 if self._pendingmode is not None and self._pendingmode != mode:
407 fp.close()
408 raise error.Abort(_('working directory state may be '
409 'changed parallelly'))
410 self._pendingmode = mode
411 return fp
412
413 401 def _read(self):
414 self._map = dirstatemap()
402 self._map = dirstatemap(self._ui, self._opener, self._root)
415 403
416 404 # ignore HG_PENDING because identity is used only for writing
417 405 self._identity = util.filestat.frompath(
418 406 self._opener.join(self._filename))
419 407 try:
420 fp = self._opendirstatefile()
408 fp = self._map._opendirstatefile()
421 409 try:
422 410 st = fp.read()
423 411 finally:
@@ -698,7 +686,7 b' class dirstate(object):'
698 686 return path
699 687
700 688 def clear(self):
701 self._map = dirstatemap()
689 self._map = dirstatemap(self._ui, self._opener, self._root)
702 690 self._nonnormalset = set()
703 691 self._otherparentset = set()
704 692 if "_dirs" in self.__dict__:
@@ -1308,10 +1296,18 b' class dirstate(object):'
1308 1296 self._opener.unlink(backupname)
1309 1297
1310 1298 class dirstatemap(object):
1311 def __init__(self):
1299 def __init__(self, ui, opener, root):
1300 self._ui = ui
1301 self._opener = opener
1302 self._root = root
1303 self._filename = 'dirstate'
1304
1312 1305 self._map = {}
1313 1306 self.copymap = {}
1314 1307
1308 # for consistent view between _pl() and _read() invocations
1309 self._pendingmode = None
1310
1315 1311 def iteritems(self):
1316 1312 return self._map.iteritems()
1317 1313
@@ -1375,3 +1371,13 b' class dirstatemap(object):'
1375 1371 current dirstate.
1376 1372 """
1377 1373 return util.dirs(self._map, 'r')
1374
1375 def _opendirstatefile(self):
1376 fp, mode = txnutil.trypending(self._root, self._opener, self._filename)
1377 if self._pendingmode is not None and self._pendingmode != mode:
1378 fp.close()
1379 raise error.Abort(_('working directory state may be '
1380 'changed parallelly'))
1381 self._pendingmode = mode
1382 return fp
1383
General Comments 0
You need to be logged in to leave comments. Login now