mercurial/branchmap.py
changeset 26587 56b2bcea2529
parent 26460 79ef867538ea
child 28364 f1460af18c50
equal deleted inserted replaced
26586:d51c658d3f04 26587:56b2bcea2529
    17     nullid,
    17     nullid,
    18     nullrev,
    18     nullrev,
    19 )
    19 )
    20 from . import (
    20 from . import (
    21     encoding,
    21     encoding,
       
    22     error,
    22     scmutil,
    23     scmutil,
    23     util,
       
    24 )
    24 )
    25 
    25 
    26 array = array.array
    26 array = array.array
    27 calcsize = struct.calcsize
    27 calcsize = struct.calcsize
    28 pack = struct.pack
    28 pack = struct.pack
   248                                             encoding.fromlocal(label)))
   248                                             encoding.fromlocal(label)))
   249             f.close()
   249             f.close()
   250             repo.ui.log('branchcache',
   250             repo.ui.log('branchcache',
   251                         'wrote %s branch cache with %d labels and %d nodes\n',
   251                         'wrote %s branch cache with %d labels and %d nodes\n',
   252                         repo.filtername, len(self), nodecount)
   252                         repo.filtername, len(self), nodecount)
   253         except (IOError, OSError, util.Abort) as inst:
   253         except (IOError, OSError, error.Abort) as inst:
   254             repo.ui.debug("couldn't write branch cache: %s\n" % inst)
   254             repo.ui.debug("couldn't write branch cache: %s\n" % inst)
   255             # Abort may be raise by read only opener
   255             # Abort may be raise by read only opener
   256             pass
   256             pass
   257 
   257 
   258     def update(self, repo, revgen):
   258     def update(self, repo, revgen):
   463                     f = repo.vfs.open(_rbcnames, 'wb')
   463                     f = repo.vfs.open(_rbcnames, 'wb')
   464                 f.write('\0'.join(encoding.fromlocal(b)
   464                 f.write('\0'.join(encoding.fromlocal(b)
   465                                   for b in self._names[self._rbcnamescount:]))
   465                                   for b in self._names[self._rbcnamescount:]))
   466                 self._rbcsnameslen = f.tell()
   466                 self._rbcsnameslen = f.tell()
   467                 f.close()
   467                 f.close()
   468             except (IOError, OSError, util.Abort) as inst:
   468             except (IOError, OSError, error.Abort) as inst:
   469                 repo.ui.debug("couldn't write revision branch cache names: "
   469                 repo.ui.debug("couldn't write revision branch cache names: "
   470                               "%s\n" % inst)
   470                               "%s\n" % inst)
   471                 return
   471                 return
   472             self._rbcnamescount = len(self._names)
   472             self._rbcnamescount = len(self._names)
   473 
   473 
   481                     f.seek(start)
   481                     f.seek(start)
   482                     f.truncate()
   482                     f.truncate()
   483                 end = revs * _rbcrecsize
   483                 end = revs * _rbcrecsize
   484                 f.write(self._rbcrevs[start:end])
   484                 f.write(self._rbcrevs[start:end])
   485                 f.close()
   485                 f.close()
   486             except (IOError, OSError, util.Abort) as inst:
   486             except (IOError, OSError, error.Abort) as inst:
   487                 repo.ui.debug("couldn't write revision branch cache: %s\n" %
   487                 repo.ui.debug("couldn't write revision branch cache: %s\n" %
   488                               inst)
   488                               inst)
   489                 return
   489                 return
   490             self._rbcrevslen = revs
   490             self._rbcrevslen = revs