mercurial/revlog.py
changeset 47145 c6b8d5d91e73
parent 47144 b6e1fe7ac24b
child 47148 a07d5cb03a85
equal deleted inserted replaced
47144:b6e1fe7ac24b 47145:c6b8d5d91e73
   287 
   287 
   288     def __init__(
   288     def __init__(
   289         self,
   289         self,
   290         opener,
   290         opener,
   291         target,
   291         target,
       
   292         postfix=None,
   292         indexfile=None,
   293         indexfile=None,
   293         datafile=None,
   294         datafile=None,
   294         checkambig=False,
   295         checkambig=False,
   295         mmaplargeindex=False,
   296         mmaplargeindex=False,
   296         censorable=False,
   297         censorable=False,
   310         analysis. Note: that this must be reliably be set by normal code, but
   311         analysis. Note: that this must be reliably be set by normal code, but
   311         that test, debug, or performance measurement code might not set this to
   312         that test, debug, or performance measurement code might not set this to
   312         accurate value.
   313         accurate value.
   313         """
   314         """
   314         self.upperboundcomp = upperboundcomp
   315         self.upperboundcomp = upperboundcomp
       
   316         if not indexfile.endswith(b'.i'):
       
   317             raise error.ProgrammingError(
       
   318                 b"revlog's indexfile should end with `.i`"
       
   319             )
       
   320         if datafile is None:
       
   321             datafile = indexfile[:-2] + b".d"
       
   322             if postfix is not None:
       
   323                 datafile = b'%s.%s' % (datafile, postfix)
       
   324         if postfix is not None:
       
   325             indexfile = b'%s.%s' % (indexfile, postfix)
   315         self.indexfile = indexfile
   326         self.indexfile = indexfile
   316         self.datafile = datafile or (indexfile[:-2] + b".d")
   327         self.datafile = datafile
   317         self.nodemap_file = None
   328         self.nodemap_file = None
       
   329         self.postfix = postfix
   318         if persistentnodemap:
   330         if persistentnodemap:
   319             self.nodemap_file = nodemaputil.get_nodemap_file(
   331             self.nodemap_file = nodemaputil.get_nodemap_file(
   320                 opener, self.indexfile
   332                 opener, self.indexfile
   321             )
   333             )
   322 
   334 
  2879             )
  2891             )
  2880 
  2892 
  2881         # Rewriting the revlog in place is hard. Our strategy for censoring is
  2893         # Rewriting the revlog in place is hard. Our strategy for censoring is
  2882         # to create a new revlog, copy all revisions to it, then replace the
  2894         # to create a new revlog, copy all revisions to it, then replace the
  2883         # revlogs on transaction close.
  2895         # revlogs on transaction close.
  2884 
  2896         #
  2885         newindexfile = self.indexfile + b'.tmpcensored'
       
  2886         newdatafile = self.datafile + b'.tmpcensored'
       
  2887 
       
  2888         # This is a bit dangerous. We could easily have a mismatch of state.
  2897         # This is a bit dangerous. We could easily have a mismatch of state.
  2889         newrl = revlog(
  2898         newrl = revlog(
  2890             self.opener,
  2899             self.opener,
  2891             target=self.target,
  2900             target=self.target,
  2892             indexfile=newindexfile,
  2901             postfix=b'tmpcensored',
  2893             datafile=newdatafile,
  2902             indexfile=self.indexfile,
  2894             censorable=True,
  2903             censorable=True,
  2895         )
  2904         )
  2896         newrl._format_version = self._format_version
  2905         newrl._format_version = self._format_version
  2897         newrl._format_flags = self._format_flags
  2906         newrl._format_flags = self._format_flags
  2898         newrl._generaldelta = self._generaldelta
  2907         newrl._generaldelta = self._generaldelta