mercurial/context.py
changeset 35295 bea46aed1e1b
parent 35294 d4f65050f3c5
child 35319 228916ca12b5
equal deleted inserted replaced
35294:d4f65050f3c5 35295:bea46aed1e1b
  2043                 raise error.ProgrammingError("No such file or directory: %s" %
  2043                 raise error.ProgrammingError("No such file or directory: %s" %
  2044                                              self._path)
  2044                                              self._path)
  2045         else:
  2045         else:
  2046             return self._wrappedctx[path].flags()
  2046             return self._wrappedctx[path].flags()
  2047 
  2047 
       
  2048     def _existsinparent(self, path):
       
  2049         try:
       
  2050             # ``commitctx` raises a ``ManifestLookupError`` if a path does not
       
  2051             # exist, unlike ``workingctx``, which returns a ``workingfilectx``
       
  2052             # with an ``exists()`` function.
       
  2053             self._wrappedctx[path]
       
  2054             return True
       
  2055         except error.ManifestLookupError:
       
  2056             return False
       
  2057 
  2048     def write(self, path, data, flags=''):
  2058     def write(self, path, data, flags=''):
  2049         if data is None:
  2059         if data is None:
  2050             raise error.ProgrammingError("data must be non-None")
  2060             raise error.ProgrammingError("data must be non-None")
  2051         self._markdirty(path, exists=True, data=data, date=util.makedate(),
  2061         self._markdirty(path, exists=True, data=data, date=util.makedate(),
  2052                         flags=flags)
  2062                         flags=flags)
  2068             if (self._cache[path]['exists'] and
  2078             if (self._cache[path]['exists'] and
  2069                         'l' in self._cache[path]['flags']):
  2079                         'l' in self._cache[path]['flags']):
  2070                 return self.exists(self._cache[path]['data'].strip())
  2080                 return self.exists(self._cache[path]['data'].strip())
  2071             else:
  2081             else:
  2072                 return self._cache[path]['exists']
  2082                 return self._cache[path]['exists']
  2073         return self._wrappedctx[path].exists()
  2083 
       
  2084         return self._existsinparent(path)
  2074 
  2085 
  2075     def lexists(self, path):
  2086     def lexists(self, path):
  2076         """lexists returns True if the path exists"""
  2087         """lexists returns True if the path exists"""
  2077         if self.isdirty(path):
  2088         if self.isdirty(path):
  2078             return self._cache[path]['exists']
  2089             return self._cache[path]['exists']
  2079         return self._wrappedctx[path].lexists()
  2090 
       
  2091         return self._existsinparent(path)
  2080 
  2092 
  2081     def size(self, path):
  2093     def size(self, path):
  2082         if self.isdirty(path):
  2094         if self.isdirty(path):
  2083             if self._cache[path]['exists']:
  2095             if self._cache[path]['exists']:
  2084                 return len(self._cache[path]['data'])
  2096                 return len(self._cache[path]['data'])