Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/context.py @ 5389:26c060922085
context: add fileflags() to avoid rebuilding manifests
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Fri, 05 Oct 2007 23:01:38 +0200 |
parents | 1fd7a99d98f6 |
children | 18f8abefdb2a |
comparison
equal
deleted
inserted
replaced
5388:557e4a916e12 | 5389:26c060922085 |
---|---|
92 def children(self): | 92 def children(self): |
93 """return contexts for each child changeset""" | 93 """return contexts for each child changeset""" |
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""" |
114 if fileid is None: | 123 if fileid is None: |
115 fileid = self.filenode(path) | 124 fileid = self.filenode(path) |
209 return filectx(self._repo, self._path, fileid=fileid, | 218 return filectx(self._repo, self._path, fileid=fileid, |
210 filelog=self._filelog) | 219 filelog=self._filelog) |
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): |
217 if '_changectx' in self.__dict__: | 229 if '_changectx' in self.__dict__: |
218 return self._changectx.rev() | 230 return self._changectx.rev() |
460 return self._parents | 472 return self._parents |
461 | 473 |
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, |
468 filelog=filelog) | 500 filelog=filelog) |
469 | 501 |