##// END OF EJS Templates
context: add fileflags() to avoid rebuilding manifests
Patrick Mezard -
r5389:26c06092 default
parent child Browse files
Show More
@@ -94,20 +94,29 b' class changectx(object):'
94 c = self._repo.changelog.children(self._node)
94 c = self._repo.changelog.children(self._node)
95 return [changectx(self._repo, x) for x in c]
95 return [changectx(self._repo, x) for x in c]
96
96
97 def filenode(self, path):
97 def _fileinfo(self, path):
98 if '_manifest' in self.__dict__:
98 if '_manifest' in self.__dict__:
99 try:
99 try:
100 return self._manifest[path]
100 return self._manifest[path], self._manifest.flags(path)
101 except KeyError:
101 except KeyError:
102 raise revlog.LookupError(_("'%s' not found in manifest") % path)
102 raise revlog.LookupError(_("'%s' not found in manifest") % path)
103 if '_manifestdelta' in self.__dict__ or path in self.files():
103 if '_manifestdelta' in self.__dict__ or path in self.files():
104 if path in self._manifestdelta:
104 if path in self._manifestdelta:
105 return self._manifestdelta[path]
105 return self._manifestdelta[path], self._manifestdelta.flags(path)
106 node, flag = self._repo.manifest.find(self._changeset[0], path)
106 node, flag = self._repo.manifest.find(self._changeset[0], path)
107 if not node:
107 if not node:
108 raise revlog.LookupError(_("'%s' not found in manifest") % path)
108 raise revlog.LookupError(_("'%s' not found in manifest") % path)
109
109
110 return node
110 return node, flag
111
112 def filenode(self, path):
113 return self._fileinfo(path)[0]
114
115 def fileflags(self, path):
116 try:
117 return self._fileinfo(path)[1]
118 except revlog.LookupError:
119 return ''
111
120
112 def filectx(self, path, fileid=None, filelog=None):
121 def filectx(self, path, fileid=None, filelog=None):
113 """get a file context from this changeset"""
122 """get a file context from this changeset"""
@@ -211,6 +220,9 b' class filectx(object):'
211
220
212 def filerev(self): return self._filerev
221 def filerev(self): return self._filerev
213 def filenode(self): return self._filenode
222 def filenode(self): return self._filenode
223 def fileflags(self): return self._changectx.fileflags(self._path)
224 def isexec(self): return 'x' in self.fileflags()
225 def islink(self): return 'l' in self.fileflags()
214 def filelog(self): return self._filelog
226 def filelog(self): return self._filelog
215
227
216 def rev(self):
228 def rev(self):
@@ -462,6 +474,26 b' class workingctx(changectx):'
462 def children(self):
474 def children(self):
463 return []
475 return []
464
476
477 def fileflags(self, path):
478 if '_manifest' in self.__dict__:
479 try:
480 return self._manifest.flags(path)
481 except KeyError:
482 return ''
483
484 pnode = self._parents[0].changeset()[0]
485 node, flag = self._repo.manifest.find(pnode, path)
486 is_link = util.linkfunc(self._repo.root, lambda: 'l' in flag)
487 is_exec = util.execfunc(self._repo.root, lambda: 'x' in flag)
488 try:
489 return (is_link(path) and 'l' or '') + (is_exec(path) and 'e' or '')
490 except OSError:
491 pass
492
493 if not node or path in self.deleted() or path in self.removed():
494 return ''
495 return flag
496
465 def filectx(self, path, filelog=None):
497 def filectx(self, path, filelog=None):
466 """get a file context from the working directory"""
498 """get a file context from the working directory"""
467 return workingfilectx(self._repo, path, workingctx=self,
499 return workingfilectx(self._repo, path, workingctx=self,
General Comments 0
You need to be logged in to leave comments. Login now