mercurial/dirstate.py
changeset 44911 fd3b94f1712d
parent 44899 4ba2a6ffcf24
parent 44780 35b255e474d9
child 45252 4f0e03d980f3
equal deleted inserted replaced
44910:708ad5cf5e5a 44911:fd3b94f1712d
   100         self._mapcls = dirstatemap
   100         self._mapcls = dirstatemap
   101         # Access and cache cwd early, so we don't access it for the first time
   101         # Access and cache cwd early, so we don't access it for the first time
   102         # after a working-copy update caused it to not exist (accessing it then
   102         # after a working-copy update caused it to not exist (accessing it then
   103         # raises an exception).
   103         # raises an exception).
   104         self._cwd
   104         self._cwd
       
   105 
       
   106     def prefetch_parents(self):
       
   107         """make sure the parents are loaded
       
   108 
       
   109         Used to avoid a race condition.
       
   110         """
       
   111         self._pl
   105 
   112 
   106     @contextlib.contextmanager
   113     @contextlib.contextmanager
   107     def parentchange(self):
   114     def parentchange(self):
   108         '''Context manager for handling dirstate parents.
   115         '''Context manager for handling dirstate parents.
   109 
   116 
  1746         def get(self, *args, **kwargs):
  1753         def get(self, *args, **kwargs):
  1747             return self._rustmap.get(*args, **kwargs)
  1754             return self._rustmap.get(*args, **kwargs)
  1748 
  1755 
  1749         @propertycache
  1756         @propertycache
  1750         def _rustmap(self):
  1757         def _rustmap(self):
  1751             self._rustmap = rustmod.DirstateMap(self._root)
  1758             """
       
  1759             Fills the Dirstatemap when called.
       
  1760             Use `self._inner_rustmap` if reading the dirstate is not necessary.
       
  1761             """
       
  1762             self._rustmap = self._inner_rustmap
  1752             self.read()
  1763             self.read()
  1753             return self._rustmap
  1764             return self._rustmap
       
  1765 
       
  1766         @propertycache
       
  1767         def _inner_rustmap(self):
       
  1768             """
       
  1769             Does not fill the Dirstatemap when called. This allows for
       
  1770             optimizations where only setting/getting the parents is needed.
       
  1771             """
       
  1772             self._inner_rustmap = rustmod.DirstateMap(self._root)
       
  1773             return self._inner_rustmap
  1754 
  1774 
  1755         @property
  1775         @property
  1756         def copymap(self):
  1776         def copymap(self):
  1757             return self._rustmap.copymap()
  1777             return self._rustmap.copymap()
  1758 
  1778 
  1759         def preload(self):
  1779         def preload(self):
  1760             self._rustmap
  1780             self._rustmap
  1761 
  1781 
  1762         def clear(self):
  1782         def clear(self):
  1763             self._rustmap.clear()
  1783             self._rustmap.clear()
       
  1784             self._inner_rustmap.clear()
  1764             self.setparents(nullid, nullid)
  1785             self.setparents(nullid, nullid)
  1765             util.clearcachedproperty(self, b"_dirs")
  1786             util.clearcachedproperty(self, b"_dirs")
  1766             util.clearcachedproperty(self, b"_alldirs")
  1787             util.clearcachedproperty(self, b"_alldirs")
  1767             util.clearcachedproperty(self, b"dirfoldmap")
  1788             util.clearcachedproperty(self, b"dirfoldmap")
  1768 
  1789 
  1815                         raise
  1836                         raise
  1816                     # File doesn't exist, so the current state is empty
  1837                     # File doesn't exist, so the current state is empty
  1817                     st = b''
  1838                     st = b''
  1818 
  1839 
  1819                 try:
  1840                 try:
  1820                     self._parents = self._rustmap.parents(st)
  1841                     self._parents = self._inner_rustmap.parents(st)
  1821                 except ValueError:
  1842                 except ValueError:
  1822                     raise error.Abort(
  1843                     raise error.Abort(
  1823                         _(b'working directory state appears damaged!')
  1844                         _(b'working directory state appears damaged!')
  1824                     )
  1845                     )
  1825 
  1846