mercurial/scmutil.py
changeset 16455 154219f3a6a4
parent 16436 e98460f6089d
child 16479 fc04698fa778
equal deleted inserted replaced
16454:92c7e917b647 16455:154219f3a6a4
   156     """Abstract base class; cannot be instantiated"""
   156     """Abstract base class; cannot be instantiated"""
   157 
   157 
   158     def __init__(self, *args, **kwargs):
   158     def __init__(self, *args, **kwargs):
   159         '''Prevent instantiation; don't call this from subclasses.'''
   159         '''Prevent instantiation; don't call this from subclasses.'''
   160         raise NotImplementedError('attempted instantiating ' + str(type(self)))
   160         raise NotImplementedError('attempted instantiating ' + str(type(self)))
       
   161 
       
   162     def tryread(self, path):
       
   163         'gracefully return an empty string for missing files'
       
   164         try:
       
   165             return self.read(path)
       
   166         except IOError, inst:
       
   167             if inst.errno != errno.ENOENT:
       
   168                 raise
       
   169         return ""
   161 
   170 
   162     def read(self, path):
   171     def read(self, path):
   163         fp = self(path, 'rb')
   172         fp = self(path, 'rb')
   164         try:
   173         try:
   165             return fp.read()
   174             return fp.read()