mercurial/obsolete.py
changeset 22950 bb8278b289ee
parent 22949 714f6ef43f3a
child 22951 6c86c673dde6
equal deleted inserted replaced
22949:714f6ef43f3a 22950:bb8278b289ee
   448     # meta:    binary blob, encoded metadata dictionary
   448     # meta:    binary blob, encoded metadata dictionary
   449     # date:    (float, int) tuple, date of marker creation
   449     # date:    (float, int) tuple, date of marker creation
   450     # parents: (tuple of nodeid) or None, parents of precursors
   450     # parents: (tuple of nodeid) or None, parents of precursors
   451     #          None is used when no data has been recorded
   451     #          None is used when no data has been recorded
   452 
   452 
   453     def __init__(self, sopener, defaultformat=_fm1version):
   453     def __init__(self, sopener, defaultformat=_fm1version, readonly=False):
   454         # caches for various obsolescence related cache
   454         # caches for various obsolescence related cache
   455         self.caches = {}
   455         self.caches = {}
   456         self._all = []
   456         self._all = []
   457         self.precursors = {}
   457         self.precursors = {}
   458         self.successors = {}
   458         self.successors = {}
   459         self.children = {}
   459         self.children = {}
   460         self.sopener = sopener
   460         self.sopener = sopener
   461         data = sopener.tryread('obsstore')
   461         data = sopener.tryread('obsstore')
   462         self._version = defaultformat
   462         self._version = defaultformat
       
   463         self._readonly = readonly
   463         if data:
   464         if data:
   464             self._version, markers = _readmarkers(data)
   465             self._version, markers = _readmarkers(data)
   465             self._load(markers)
   466             self._load(markers)
   466 
   467 
   467     def __iter__(self):
   468     def __iter__(self):
   511     def add(self, transaction, markers):
   512     def add(self, transaction, markers):
   512         """Add new markers to the store
   513         """Add new markers to the store
   513 
   514 
   514         Take care of filtering duplicate.
   515         Take care of filtering duplicate.
   515         Return the number of new marker."""
   516         Return the number of new marker."""
   516         if not _enabled:
   517         if self._readonly:
   517             raise util.Abort('obsolete feature is not enabled on this repo')
   518             raise util.Abort('creating obsolete markers is not enabled on this '
       
   519                              'repo')
   518         known = set(self._all)
   520         known = set(self._all)
   519         new = []
   521         new = []
   520         for m in markers:
   522         for m in markers:
   521             if m not in known:
   523             if m not in known:
   522                 known.add(m)
   524                 known.add(m)