mercurial/obsolete.py
branchstable
changeset 48796 c00d3ce4e94b
parent 48789 ef50a62eec40
child 48875 6000f5b25c9b
equal deleted inserted replaced
48776:b84ff512b645 48796:c00d3ce4e94b
    71 
    71 
    72 import errno
    72 import errno
    73 import struct
    73 import struct
    74 
    74 
    75 from .i18n import _
    75 from .i18n import _
    76 from .node import (
       
    77     bin,
       
    78     hex,
       
    79 )
       
    80 from .pycompat import getattr
    76 from .pycompat import getattr
    81 from .node import (
    77 from .node import (
    82     bin,
    78     bin,
    83     hex,
    79     hex,
    84 )
    80 )
   577 
   573 
   578     def __len__(self):
   574     def __len__(self):
   579         return len(self._all)
   575         return len(self._all)
   580 
   576 
   581     def __nonzero__(self):
   577     def __nonzero__(self):
       
   578         from . import statichttprepo
       
   579 
       
   580         if isinstance(self.repo, statichttprepo.statichttprepository):
       
   581             # If repo is accessed via static HTTP, then we can't use os.stat()
       
   582             # to just peek at the file size.
       
   583             return len(self._data) > 1
   582         if not self._cached('_all'):
   584         if not self._cached('_all'):
   583             try:
   585             try:
   584                 return self.svfs.stat(b'obsstore').st_size > 1
   586                 return self.svfs.stat(b'obsstore').st_size > 1
   585             except OSError as inst:
   587             except OSError as inst:
   586                 if inst.errno != errno.ENOENT:
   588                 if inst.errno != errno.ENOENT:
   942 def _computeobsoleteset(repo):
   944 def _computeobsoleteset(repo):
   943     """the set of obsolete revisions"""
   945     """the set of obsolete revisions"""
   944     getnode = repo.changelog.node
   946     getnode = repo.changelog.node
   945     notpublic = _mutablerevs(repo)
   947     notpublic = _mutablerevs(repo)
   946     isobs = repo.obsstore.successors.__contains__
   948     isobs = repo.obsstore.successors.__contains__
   947     obs = {r for r in notpublic if isobs(getnode(r))}
   949     return frozenset(r for r in notpublic if isobs(getnode(r)))
   948     return obs
       
   949 
   950 
   950 
   951 
   951 @cachefor(b'orphan')
   952 @cachefor(b'orphan')
   952 def _computeorphanset(repo):
   953 def _computeorphanset(repo):
   953     """the set of non obsolete revisions with obsolete parents"""
   954     """the set of non obsolete revisions with obsolete parents"""
   961         # this works since we traverse following growing rev order
   962         # this works since we traverse following growing rev order
   962         for p in pfunc(r):
   963         for p in pfunc(r):
   963             if p in obsolete or p in unstable:
   964             if p in obsolete or p in unstable:
   964                 unstable.add(r)
   965                 unstable.add(r)
   965                 break
   966                 break
   966     return unstable
   967     return frozenset(unstable)
   967 
   968 
   968 
   969 
   969 @cachefor(b'suspended')
   970 @cachefor(b'suspended')
   970 def _computesuspendedset(repo):
   971 def _computesuspendedset(repo):
   971     """the set of obsolete parents with non obsolete descendants"""
   972     """the set of obsolete parents with non obsolete descendants"""
   972     suspended = repo.changelog.ancestors(getrevs(repo, b'orphan'))
   973     suspended = repo.changelog.ancestors(getrevs(repo, b'orphan'))
   973     return {r for r in getrevs(repo, b'obsolete') if r in suspended}
   974     return frozenset(r for r in getrevs(repo, b'obsolete') if r in suspended)
   974 
   975 
   975 
   976 
   976 @cachefor(b'extinct')
   977 @cachefor(b'extinct')
   977 def _computeextinctset(repo):
   978 def _computeextinctset(repo):
   978     """the set of obsolete parents without non obsolete descendants"""
   979     """the set of obsolete parents without non obsolete descendants"""
  1000             prev = torev(pnode)  # unfiltered! but so is phasecache
  1001             prev = torev(pnode)  # unfiltered! but so is phasecache
  1001             if (prev is not None) and (phase(repo, prev) <= public):
  1002             if (prev is not None) and (phase(repo, prev) <= public):
  1002                 # we have a public predecessor
  1003                 # we have a public predecessor
  1003                 bumped.add(rev)
  1004                 bumped.add(rev)
  1004                 break  # Next draft!
  1005                 break  # Next draft!
  1005     return bumped
  1006     return frozenset(bumped)
  1006 
  1007 
  1007 
  1008 
  1008 @cachefor(b'contentdivergent')
  1009 @cachefor(b'contentdivergent')
  1009 def _computecontentdivergentset(repo):
  1010 def _computecontentdivergentset(repo):
  1010     """the set of rev that compete to be the final successors of some revision."""
  1011     """the set of rev that compete to be the final successors of some revision."""
  1027             newer = [n for n in newermap[prec] if n]
  1028             newer = [n for n in newermap[prec] if n]
  1028             if len(newer) > 1:
  1029             if len(newer) > 1:
  1029                 divergent.add(rev)
  1030                 divergent.add(rev)
  1030                 break
  1031                 break
  1031             toprocess.update(obsstore.predecessors.get(prec, ()))
  1032             toprocess.update(obsstore.predecessors.get(prec, ()))
  1032     return divergent
  1033     return frozenset(divergent)
  1033 
  1034 
  1034 
  1035 
  1035 def makefoldid(relation, user):
  1036 def makefoldid(relation, user):
  1036 
  1037 
  1037     folddigest = hashutil.sha1(user)
  1038     folddigest = hashutil.sha1(user)