2094 try: |
2094 try: |
2095 self._writinghandles = (ifh, dfh) |
2095 self._writinghandles = (ifh, dfh) |
2096 try: |
2096 try: |
2097 yield |
2097 yield |
2098 if self._docket is not None: |
2098 if self._docket is not None: |
2099 self._docket.write(transaction) |
2099 self._write_docket(transaction) |
2100 finally: |
2100 finally: |
2101 self._writinghandles = None |
2101 self._writinghandles = None |
2102 finally: |
2102 finally: |
2103 ifh.close() |
2103 ifh.close() |
2104 finally: |
2104 finally: |
2105 if dfh is not None: |
2105 if dfh is not None: |
2106 dfh.close() |
2106 dfh.close() |
|
2107 |
|
2108 def _write_docket(self, transaction): |
|
2109 """write the current docket on disk |
|
2110 |
|
2111 Exist as a method to help changelog to implement transaction logic |
|
2112 |
|
2113 We could also imagine using the same transaction logic for all revlog |
|
2114 since docket are cheap.""" |
|
2115 self._docket.write(transaction) |
2107 |
2116 |
2108 def addrevision( |
2117 def addrevision( |
2109 self, |
2118 self, |
2110 text, |
2119 text, |
2111 transaction, |
2120 transaction, |
3185 assert not self._inline |
3194 assert not self._inline |
3186 if not helpers[1] and not helpers[2]: |
3195 if not helpers[1] and not helpers[2]: |
3187 # Nothing to generate or remove |
3196 # Nothing to generate or remove |
3188 return |
3197 return |
3189 |
3198 |
3190 # changelog implement some "delayed" writing mechanism that assume that |
|
3191 # all index data is writen in append mode and is therefor incompatible |
|
3192 # with the seeked write done in this method. The use of such "delayed" |
|
3193 # writing will soon be removed for revlog version that support side |
|
3194 # data, so for now, we only keep this simple assert to highlight the |
|
3195 # situation. |
|
3196 delayed = getattr(self, '_delayed', False) |
|
3197 diverted = getattr(self, '_divert', False) |
|
3198 if delayed and not diverted: |
|
3199 msg = "cannot rewrite_sidedata of a delayed revlog" |
|
3200 raise error.ProgrammingError(msg) |
|
3201 |
|
3202 new_entries = [] |
3199 new_entries = [] |
3203 # append the new sidedata |
3200 # append the new sidedata |
3204 with self._writing(transaction): |
3201 with self._writing(transaction): |
3205 ifh, dfh = self._writinghandles |
3202 ifh, dfh = self._writinghandles |
3206 dfh.seek(0, os.SEEK_END) |
3203 dfh.seek(0, os.SEEK_END) |