mercurial/obsolete.py
changeset 33479 8b48dad66be4
parent 33273 5724aaa99dd6
child 33499 0407a51b9d8c
equal deleted inserted replaced
33478:cf15c3cc304c 33479:8b48dad66be4
   605             f = self.svfs('obsstore', 'ab')
   605             f = self.svfs('obsstore', 'ab')
   606             try:
   606             try:
   607                 offset = f.tell()
   607                 offset = f.tell()
   608                 transaction.add('obsstore', offset)
   608                 transaction.add('obsstore', offset)
   609                 # offset == 0: new file - add the version header
   609                 # offset == 0: new file - add the version header
   610                 for bytes in encodemarkers(new, offset == 0, self._version):
   610                 data = b''.join(encodemarkers(new, offset == 0, self._version))
   611                     f.write(bytes)
   611                 f.write(data)
   612             finally:
   612             finally:
   613                 # XXX: f.close() == filecache invalidation == obsstore rebuilt.
   613                 # XXX: f.close() == filecache invalidation == obsstore rebuilt.
   614                 # call 'filecacheentry.refresh()'  here
   614                 # call 'filecacheentry.refresh()'  here
   615                 f.close()
   615                 f.close()
   616             addedmarkers = transaction.changes.get('obsmarkers')
   616             addedmarkers = transaction.changes.get('obsmarkers')
   617             if addedmarkers is not None:
   617             if addedmarkers is not None:
   618                 addedmarkers.update(new)
   618                 addedmarkers.update(new)
   619             self._addmarkers(new)
   619             self._addmarkers(new, data)
   620             # new marker *may* have changed several set. invalidate the cache.
   620             # new marker *may* have changed several set. invalidate the cache.
   621             self.caches.clear()
   621             self.caches.clear()
   622         # records the number of new markers for the transaction hooks
   622         # records the number of new markers for the transaction hooks
   623         previous = int(transaction.hookargs.get('new_obsmarkers', '0'))
   623         previous = int(transaction.hookargs.get('new_obsmarkers', '0'))
   624         transaction.hookargs['new_obsmarkers'] = str(previous + len(new))
   624         transaction.hookargs['new_obsmarkers'] = str(previous + len(new))
   671         return children
   671         return children
   672 
   672 
   673     def _cached(self, attr):
   673     def _cached(self, attr):
   674         return attr in self.__dict__
   674         return attr in self.__dict__
   675 
   675 
   676     def _addmarkers(self, markers):
   676     def _addmarkers(self, markers, rawdata):
   677         markers = list(markers) # to allow repeated iteration
   677         markers = list(markers) # to allow repeated iteration
       
   678         self._data = self._data + rawdata
   678         self._all.extend(markers)
   679         self._all.extend(markers)
   679         if self._cached('successors'):
   680         if self._cached('successors'):
   680             _addsuccessors(self.successors, markers)
   681             _addsuccessors(self.successors, markers)
   681         if self._cached('precursors'):
   682         if self._cached('precursors'):
   682             _addprecursors(self.precursors, markers)
   683             _addprecursors(self.precursors, markers)