Show More
@@ -1425,6 +1425,7 class dirstatemap(object): | |||||
1425 | self._opener = opener |
|
1425 | self._opener = opener | |
1426 | self._root = root |
|
1426 | self._root = root | |
1427 | self._filename = b'dirstate' |
|
1427 | self._filename = b'dirstate' | |
|
1428 | self._nodelen = 20 | |||
1428 |
|
1429 | |||
1429 | self._parents = None |
|
1430 | self._parents = None | |
1430 | self._dirtyparents = False |
|
1431 | self._dirtyparents = False | |
@@ -1609,7 +1610,7 class dirstatemap(object): | |||||
1609 | if not self._parents: |
|
1610 | if not self._parents: | |
1610 | try: |
|
1611 | try: | |
1611 | fp = self._opendirstatefile() |
|
1612 | fp = self._opendirstatefile() | |
1612 |
st = fp.read( |
|
1613 | st = fp.read(2 * self._nodelen) | |
1613 | fp.close() |
|
1614 | fp.close() | |
1614 | except IOError as err: |
|
1615 | except IOError as err: | |
1615 | if err.errno != errno.ENOENT: |
|
1616 | if err.errno != errno.ENOENT: | |
@@ -1618,8 +1619,11 class dirstatemap(object): | |||||
1618 | st = b'' |
|
1619 | st = b'' | |
1619 |
|
1620 | |||
1620 | l = len(st) |
|
1621 | l = len(st) | |
1621 |
if l == |
|
1622 | if l == self._nodelen * 2: | |
1622 |
self._parents = ( |
|
1623 | self._parents = ( | |
|
1624 | st[: self._nodelen], | |||
|
1625 | st[self._nodelen : 2 * self._nodelen], | |||
|
1626 | ) | |||
1623 | elif l == 0: |
|
1627 | elif l == 0: | |
1624 | self._parents = (nullid, nullid) |
|
1628 | self._parents = (nullid, nullid) | |
1625 | else: |
|
1629 | else: | |
@@ -1655,15 +1659,17 class dirstatemap(object): | |||||
1655 | if util.safehasattr(parsers, b'dict_new_presized'): |
|
1659 | if util.safehasattr(parsers, b'dict_new_presized'): | |
1656 | # Make an estimate of the number of files in the dirstate based on |
|
1660 | # Make an estimate of the number of files in the dirstate based on | |
1657 | # its size. From a linear regression on a set of real-world repos, |
|
1661 | # its size. From a linear regression on a set of real-world repos, | |
1658 |
# all over 10,000 files, the size of a dirstate entry is |
|
1662 | # all over 10,000 files, the size of a dirstate entry is 2 nodes | |
1659 | # bytes. The cost of resizing is significantly higher than the cost |
|
1663 | # plus 45 bytes. The cost of resizing is significantly higher than the cost | |
1660 | # of filling in a larger presized dict, so subtract 20% from the |
|
1664 | # of filling in a larger presized dict, so subtract 20% from the | |
1661 | # size. |
|
1665 | # size. | |
1662 | # |
|
1666 | # | |
1663 | # This heuristic is imperfect in many ways, so in a future dirstate |
|
1667 | # This heuristic is imperfect in many ways, so in a future dirstate | |
1664 | # format update it makes sense to just record the number of entries |
|
1668 | # format update it makes sense to just record the number of entries | |
1665 | # on write. |
|
1669 | # on write. | |
1666 |
self._map = parsers.dict_new_presized( |
|
1670 | self._map = parsers.dict_new_presized( | |
|
1671 | len(st) // ((2 * self._nodelen + 45) * 4 // 5) | |||
|
1672 | ) | |||
1667 |
|
1673 | |||
1668 | # Python's garbage collector triggers a GC each time a certain number |
|
1674 | # Python's garbage collector triggers a GC each time a certain number | |
1669 | # of container objects (the number being defined by |
|
1675 | # of container objects (the number being defined by | |
@@ -1829,7 +1835,7 if rustmod is not None: | |||||
1829 | if not self._parents: |
|
1835 | if not self._parents: | |
1830 | try: |
|
1836 | try: | |
1831 | fp = self._opendirstatefile() |
|
1837 | fp = self._opendirstatefile() | |
1832 |
st = fp.read( |
|
1838 | st = fp.read(2 * self._nodelen) | |
1833 | fp.close() |
|
1839 | fp.close() | |
1834 | except IOError as err: |
|
1840 | except IOError as err: | |
1835 | if err.errno != errno.ENOENT: |
|
1841 | if err.errno != errno.ENOENT: |
General Comments 0
You need to be logged in to leave comments.
Login now