mercurial/context.py
changeset 7633 08cabecfa8a8
parent 7516 a8376f2aa3b1
child 7874 d812029cda85
child 8061 26316dda374f
equal deleted inserted replaced
7632:9626819b2e3d 7633:08cabecfa8a8
     5 # This software may be used and distributed according to the terms
     5 # This software may be used and distributed according to the terms
     6 # of the GNU General Public License, incorporated herein by reference.
     6 # of the GNU General Public License, incorporated herein by reference.
     7 
     7 
     8 from node import nullid, nullrev, short, hex
     8 from node import nullid, nullrev, short, hex
     9 from i18n import _
     9 from i18n import _
    10 import ancestor, bdiff, revlog, util, os, errno
    10 import ancestor, bdiff, error, util, os, errno
    11 
    11 
    12 class propertycache(object):
    12 class propertycache(object):
    13     def __init__(self, func):
    13     def __init__(self, func):
    14         self.func = func
    14         self.func = func
    15         self.name = func.__name__
    15         self.name = func.__name__
   123     def _fileinfo(self, path):
   123     def _fileinfo(self, path):
   124         if '_manifest' in self.__dict__:
   124         if '_manifest' in self.__dict__:
   125             try:
   125             try:
   126                 return self._manifest[path], self._manifest.flags(path)
   126                 return self._manifest[path], self._manifest.flags(path)
   127             except KeyError:
   127             except KeyError:
   128                 raise revlog.LookupError(self._node, path,
   128                 raise error.LookupError(self._node, path,
   129                                          _('not found in manifest'))
   129                                         _('not found in manifest'))
   130         if '_manifestdelta' in self.__dict__ or path in self.files():
   130         if '_manifestdelta' in self.__dict__ or path in self.files():
   131             if path in self._manifestdelta:
   131             if path in self._manifestdelta:
   132                 return self._manifestdelta[path], self._manifestdelta.flags(path)
   132                 return self._manifestdelta[path], self._manifestdelta.flags(path)
   133         node, flag = self._repo.manifest.find(self._changeset[0], path)
   133         node, flag = self._repo.manifest.find(self._changeset[0], path)
   134         if not node:
   134         if not node:
   135             raise revlog.LookupError(self._node, path,
   135             raise error.LookupError(self._node, path,
   136                                      _('not found in manifest'))
   136                                     _('not found in manifest'))
   137 
   137 
   138         return node, flag
   138         return node, flag
   139 
   139 
   140     def filenode(self, path):
   140     def filenode(self, path):
   141         return self._fileinfo(path)[0]
   141         return self._fileinfo(path)[0]
   142 
   142 
   143     def flags(self, path):
   143     def flags(self, path):
   144         try:
   144         try:
   145             return self._fileinfo(path)[1]
   145             return self._fileinfo(path)[1]
   146         except revlog.LookupError:
   146         except error.LookupError:
   147             return ''
   147             return ''
   148 
   148 
   149     def filectx(self, path, fileid=None, filelog=None):
   149     def filectx(self, path, fileid=None, filelog=None):
   150         """get a file context from this changeset"""
   150         """get a file context from this changeset"""
   151         if fileid is None:
   151         if fileid is None:
   233 
   233 
   234     def __nonzero__(self):
   234     def __nonzero__(self):
   235         try:
   235         try:
   236             n = self._filenode
   236             n = self._filenode
   237             return True
   237             return True
   238         except revlog.LookupError:
   238         except error.LookupError:
   239             # file is missing
   239             # file is missing
   240             return False
   240             return False
   241 
   241 
   242     def __str__(self):
   242     def __str__(self):
   243         return "%s@%s" % (self.path(), short(self.node()))
   243         return "%s@%s" % (self.path(), short(self.node()))
   314         fnode = self._filenode
   314         fnode = self._filenode
   315         for p in self._changectx.parents():
   315         for p in self._changectx.parents():
   316             try:
   316             try:
   317                 if fnode == p.filenode(name):
   317                 if fnode == p.filenode(name):
   318                     return None
   318                     return None
   319             except revlog.LookupError:
   319             except error.LookupError:
   320                 pass
   320                 pass
   321         return renamed
   321         return renamed
   322 
   322 
   323     def parents(self):
   323     def parents(self):
   324         p = self._path
   324         p = self._path