##// END OF EJS Templates
Make filectx lazier - some users never use filenode
Brendan Cully -
r3144:8342ad5a default
parent child Browse files
Show More
@@ -102,34 +102,35 b' class filectx(object):'
102 self._filelog = self._repo.file(self._path)
102 self._filelog = self._repo.file(self._path)
103
103
104 if fileid is None:
104 if fileid is None:
105 # if given a changeset id, go ahead and look up the file
106 self._changeid = changeid
105 self._changeid = changeid
107 self._changectx = self.changectx()
108 self._filenode = self._changectx.filenode(self._path)
109 else:
106 else:
110 # else delay changectx creation
111 self._filenode = self._filelog.lookup(fileid)
107 self._filenode = self._filelog.lookup(fileid)
112 self._changeid = self._filelog.linkrev(self._filenode)
108 self._changeid = self._filelog.linkrev(self._filenode)
113 self._filerev = self._filelog.rev(self._filenode)
114
109
115 def changectx(self):
110 def __getattr__(self, name):
116 try:
111 if name == '_changectx':
117 return self._changectx
118 except AttributeError:
119 self._changectx = changectx(self._repo, self._changeid)
112 self._changectx = changectx(self._repo, self._changeid)
120 return self._changectx
113 return self._changectx
114 elif name == '_filenode':
115 self._filenode = self._changectx.filenode(self._path)
116 return self._filenode
117 elif name == '_filerev':
118 self._filerev = self._filelog.rev(self._filenode)
119 return self._filerev
120 else:
121 raise AttributeError, name
121
122
122 def filerev(self): return self._filerev
123 def filerev(self): return self._filerev
123 def filenode(self): return self._filenode
124 def filenode(self): return self._filenode
124 def filelog(self): return self._filelog
125 def filelog(self): return self._filelog
125
126
126 def rev(self): return self.changectx().rev()
127 def rev(self): return self._changectx.rev()
127 def node(self): return self.changectx().node()
128 def node(self): return self._changectx.node()
128 def user(self): return self.changectx().user()
129 def user(self): return self._changectx.user()
129 def date(self): return self.changectx().date()
130 def date(self): return self._changectx.date()
130 def files(self): return self.changectx().files()
131 def files(self): return self._changectx.files()
131 def description(self): return self.changectx().description()
132 def description(self): return self._changectx.description()
132 def manifest(self): return self.changectx().manifest()
133 def manifest(self): return self._changectx.manifest()
133
134
134 def data(self): return self._filelog.read(self._filenode)
135 def data(self): return self._filelog.read(self._filenode)
135 def renamed(self): return self._filelog.renamed(self._filenode)
136 def renamed(self): return self._filelog.renamed(self._filenode)
General Comments 0
You need to be logged in to leave comments. Login now