Show More
@@ -8,6 +8,7 b'' | |||||
8 | from __future__ import absolute_import |
|
8 | from __future__ import absolute_import | |
9 |
|
9 | |||
10 | import collections |
|
10 | import collections | |
|
11 | import contextlib | |||
11 | import errno |
|
12 | import errno | |
12 | import os |
|
13 | import os | |
13 | import stat |
|
14 | import stat | |
@@ -99,6 +100,23 b' class dirstate(object):' | |||||
99 | # for consistent view between _pl() and _read() invocations |
|
100 | # for consistent view between _pl() and _read() invocations | |
100 | self._pendingmode = None |
|
101 | self._pendingmode = None | |
101 |
|
102 | |||
|
103 | @contextlib.contextmanager | |||
|
104 | def parentchange(self): | |||
|
105 | '''Context manager for handling dirstate parents. | |||
|
106 | ||||
|
107 | If an exception occurs in the scope of the context manager, | |||
|
108 | the incoherent dirstate won't be written when wlock is | |||
|
109 | released. | |||
|
110 | ''' | |||
|
111 | self._parentwriters += 1 | |||
|
112 | yield | |||
|
113 | # Typically we want the "undo" step of a context manager in a | |||
|
114 | # finally block so it happens even when an exception | |||
|
115 | # occurs. In this case, however, we only want to decrement | |||
|
116 | # parentwriters if the code in the with statement exits | |||
|
117 | # normally, so we don't have a try/finally here on purpose. | |||
|
118 | self._parentwriters -= 1 | |||
|
119 | ||||
102 | def beginparentchange(self): |
|
120 | def beginparentchange(self): | |
103 | '''Marks the beginning of a set of changes that involve changing |
|
121 | '''Marks the beginning of a set of changes that involve changing | |
104 | the dirstate parents. If there is an exception during this time, |
|
122 | the dirstate parents. If there is an exception during this time, |
General Comments 0
You need to be logged in to leave comments.
Login now