1298 """helper function to know if incoming delta should be optimised |
1298 """helper function to know if incoming delta should be optimised |
1299 """ |
1299 """ |
1300 # experimental config: format.generaldelta |
1300 # experimental config: format.generaldelta |
1301 return ui.configbool('format', 'generaldelta', False) |
1301 return ui.configbool('format', 'generaldelta', False) |
1302 |
1302 |
1303 class delayclosedfile(object): |
1303 class closewrapbase(object): |
1304 """Proxy for a file object whose close is delayed. |
1304 """Base class of wrapper, which hooks closing |
1305 |
1305 |
1306 Do not instantiate outside of the vfs layer. |
1306 Do not instantiate outside of the vfs layer. |
1307 """ |
1307 """ |
1308 |
1308 def __init__(self, fh): |
1309 def __init__(self, fh, closer): |
|
1310 object.__setattr__(self, '_origfh', fh) |
1309 object.__setattr__(self, '_origfh', fh) |
1311 object.__setattr__(self, '_closer', closer) |
|
1312 |
1310 |
1313 def __getattr__(self, attr): |
1311 def __getattr__(self, attr): |
1314 return getattr(self._origfh, attr) |
1312 return getattr(self._origfh, attr) |
1315 |
1313 |
1316 def __setattr__(self, attr, value): |
1314 def __setattr__(self, attr, value): |
1319 def __delattr__(self, attr): |
1317 def __delattr__(self, attr): |
1320 return delattr(self._origfh, attr) |
1318 return delattr(self._origfh, attr) |
1321 |
1319 |
1322 def __enter__(self): |
1320 def __enter__(self): |
1323 return self._origfh.__enter__() |
1321 return self._origfh.__enter__() |
|
1322 |
|
1323 def __exit__(self, exc_type, exc_value, exc_tb): |
|
1324 raise NotImplementedError('attempted instantiating ' + str(type(self))) |
|
1325 |
|
1326 def close(self): |
|
1327 raise NotImplementedError('attempted instantiating ' + str(type(self))) |
|
1328 |
|
1329 class delayclosedfile(closewrapbase): |
|
1330 """Proxy for a file object whose close is delayed. |
|
1331 |
|
1332 Do not instantiate outside of the vfs layer. |
|
1333 """ |
|
1334 def __init__(self, fh, closer): |
|
1335 super(delayclosedfile, self).__init__(fh) |
|
1336 object.__setattr__(self, '_closer', closer) |
1324 |
1337 |
1325 def __exit__(self, exc_type, exc_value, exc_tb): |
1338 def __exit__(self, exc_type, exc_value, exc_tb): |
1326 self._closer.close(self._origfh) |
1339 self._closer.close(self._origfh) |
1327 |
1340 |
1328 def close(self): |
1341 def close(self): |