Show More
@@ -1742,7 +1742,8 b' class workingctx(committablectx):' | |||||
1742 |
|
1742 | |||
1743 | def _poststatusfixup(self, status, fixup): |
|
1743 | def _poststatusfixup(self, status, fixup): | |
1744 | """update dirstate for files that are actually clean""" |
|
1744 | """update dirstate for files that are actually clean""" | |
1745 | if fixup: |
|
1745 | poststatus = self._repo.postdsstatus() | |
|
1746 | if fixup or poststatus: | |||
1746 | try: |
|
1747 | try: | |
1747 | oldid = self._repo.dirstate.identity() |
|
1748 | oldid = self._repo.dirstate.identity() | |
1748 |
|
1749 | |||
@@ -1752,15 +1753,20 b' class workingctx(committablectx):' | |||||
1752 | # taking the lock |
|
1753 | # taking the lock | |
1753 | with self._repo.wlock(False): |
|
1754 | with self._repo.wlock(False): | |
1754 | if self._repo.dirstate.identity() == oldid: |
|
1755 | if self._repo.dirstate.identity() == oldid: | |
1755 | normal = self._repo.dirstate.normal |
|
1756 | if fixup: | |
1756 | for f in fixup: |
|
1757 | normal = self._repo.dirstate.normal | |
1757 |
|
|
1758 | for f in fixup: | |
1758 | # write changes out explicitly, because nesting |
|
1759 | normal(f) | |
1759 | # wlock at runtime may prevent 'wlock.release()' |
|
1760 | # write changes out explicitly, because nesting | |
1760 | # after this block from doing so for subsequent |
|
1761 | # wlock at runtime may prevent 'wlock.release()' | |
1761 | # changing files |
|
1762 | # after this block from doing so for subsequent | |
1762 | tr = self._repo.currenttransaction() |
|
1763 | # changing files | |
1763 |
self._repo. |
|
1764 | tr = self._repo.currenttransaction() | |
|
1765 | self._repo.dirstate.write(tr) | |||
|
1766 | ||||
|
1767 | if poststatus: | |||
|
1768 | for ps in poststatus: | |||
|
1769 | ps(self, status) | |||
1764 | else: |
|
1770 | else: | |
1765 | # in this case, writing changes out breaks |
|
1771 | # in this case, writing changes out breaks | |
1766 | # consistency, because .hg/dirstate was |
|
1772 | # consistency, because .hg/dirstate was | |
@@ -1770,6 +1776,9 b' class workingctx(committablectx):' | |||||
1770 | 'identity mismatch\n') |
|
1776 | 'identity mismatch\n') | |
1771 | except error.LockError: |
|
1777 | except error.LockError: | |
1772 | pass |
|
1778 | pass | |
|
1779 | finally: | |||
|
1780 | # Even if the wlock couldn't be grabbed, clear out the list. | |||
|
1781 | self._repo.clearpostdsstatus() | |||
1773 |
|
1782 | |||
1774 | def _dirstatestatus(self, match=None, ignored=False, clean=False, |
|
1783 | def _dirstatestatus(self, match=None, ignored=False, clean=False, | |
1775 | unknown=False): |
|
1784 | unknown=False): |
@@ -400,6 +400,9 b' class localrepository(object):' | |||||
400 | # - bookmark changes |
|
400 | # - bookmark changes | |
401 | self.filteredrevcache = {} |
|
401 | self.filteredrevcache = {} | |
402 |
|
402 | |||
|
403 | # post-dirstate-status hooks | |||
|
404 | self._postdsstatus = [] | |||
|
405 | ||||
403 | # generic mapping between names and nodes |
|
406 | # generic mapping between names and nodes | |
404 | self.names = namespaces.namespaces() |
|
407 | self.names = namespaces.namespaces() | |
405 |
|
408 | |||
@@ -1884,6 +1887,36 b' class localrepository(object):' | |||||
1884 | return self[node1].status(node2, match, ignored, clean, unknown, |
|
1887 | return self[node1].status(node2, match, ignored, clean, unknown, | |
1885 | listsubrepos) |
|
1888 | listsubrepos) | |
1886 |
|
1889 | |||
|
1890 | def addpostdsstatus(self, ps): | |||
|
1891 | """Add a callback to run within the wlock, at the point at which status | |||
|
1892 | fixups happen. | |||
|
1893 | ||||
|
1894 | On status completion, callback(wctx, status) will be called with the | |||
|
1895 | wlock held, unless the dirstate has changed from underneath or the wlock | |||
|
1896 | couldn't be grabbed. | |||
|
1897 | ||||
|
1898 | Callbacks should not capture and use a cached copy of the dirstate -- | |||
|
1899 | it might change in the meanwhile. Instead, they should access the | |||
|
1900 | dirstate via wctx.repo().dirstate. | |||
|
1901 | ||||
|
1902 | This list is emptied out after each status run -- extensions should | |||
|
1903 | make sure it adds to this list each time dirstate.status is called. | |||
|
1904 | Extensions should also make sure they don't call this for statuses | |||
|
1905 | that don't involve the dirstate. | |||
|
1906 | """ | |||
|
1907 | ||||
|
1908 | # The list is located here for uniqueness reasons -- it is actually | |||
|
1909 | # managed by the workingctx, but that isn't unique per-repo. | |||
|
1910 | self._postdsstatus.append(ps) | |||
|
1911 | ||||
|
1912 | def postdsstatus(self): | |||
|
1913 | """Used by workingctx to get the list of post-dirstate-status hooks.""" | |||
|
1914 | return self._postdsstatus | |||
|
1915 | ||||
|
1916 | def clearpostdsstatus(self): | |||
|
1917 | """Used by workingctx to clear post-dirstate-status hooks.""" | |||
|
1918 | del self._postdsstatus[:] | |||
|
1919 | ||||
1887 | def heads(self, start=None): |
|
1920 | def heads(self, start=None): | |
1888 | if start is None: |
|
1921 | if start is None: | |
1889 | cl = self.changelog |
|
1922 | cl = self.changelog |
General Comments 0
You need to be logged in to leave comments.
Login now