1203 self._changectx = ctx |
1203 self._changectx = ctx |
1204 |
1204 |
1205 def __nonzero__(self): |
1205 def __nonzero__(self): |
1206 return True |
1206 return True |
1207 |
1207 |
|
1208 def parents(self): |
|
1209 '''return parent filectxs, following copies if necessary''' |
|
1210 def filenode(ctx, path): |
|
1211 return ctx._manifest.get(path, nullid) |
|
1212 |
|
1213 path = self._path |
|
1214 fl = self._filelog |
|
1215 pcl = self._changectx._parents |
|
1216 renamed = self.renamed() |
|
1217 |
|
1218 if renamed: |
|
1219 pl = [renamed + (None,)] |
|
1220 else: |
|
1221 pl = [(path, filenode(pcl[0], path), fl)] |
|
1222 |
|
1223 for pc in pcl[1:]: |
|
1224 pl.append((path, filenode(pc, path), fl)) |
|
1225 |
|
1226 return [filectx(self._repo, p, fileid=n, filelog=l) |
|
1227 for p, n, l in pl if n != nullid] |
|
1228 |
1208 class workingfilectx(commitablefilectx): |
1229 class workingfilectx(commitablefilectx): |
1209 """A workingfilectx object makes access to data related to a particular |
1230 """A workingfilectx object makes access to data related to a particular |
1210 file in the working directory convenient.""" |
1231 file in the working directory convenient.""" |
1211 def __init__(self, repo, path, filelog=None, workingctx=None): |
1232 def __init__(self, repo, path, filelog=None, workingctx=None): |
1212 super(workingfilectx, self).__init__(repo, path, filelog, workingctx) |
1233 super(workingfilectx, self).__init__(repo, path, filelog, workingctx) |
1220 def renamed(self): |
1241 def renamed(self): |
1221 rp = self._repo.dirstate.copied(self._path) |
1242 rp = self._repo.dirstate.copied(self._path) |
1222 if not rp: |
1243 if not rp: |
1223 return None |
1244 return None |
1224 return rp, self._changectx._parents[0]._manifest.get(rp, nullid) |
1245 return rp, self._changectx._parents[0]._manifest.get(rp, nullid) |
1225 |
|
1226 def parents(self): |
|
1227 '''return parent filectxs, following copies if necessary''' |
|
1228 def filenode(ctx, path): |
|
1229 return ctx._manifest.get(path, nullid) |
|
1230 |
|
1231 path = self._path |
|
1232 fl = self._filelog |
|
1233 pcl = self._changectx._parents |
|
1234 renamed = self.renamed() |
|
1235 |
|
1236 if renamed: |
|
1237 pl = [renamed + (None,)] |
|
1238 else: |
|
1239 pl = [(path, filenode(pcl[0], path), fl)] |
|
1240 |
|
1241 for pc in pcl[1:]: |
|
1242 pl.append((path, filenode(pc, path), fl)) |
|
1243 |
|
1244 return [filectx(self._repo, p, fileid=n, filelog=l) |
|
1245 for p, n, l in pl if n != nullid] |
|
1246 |
1246 |
1247 def children(self): |
1247 def children(self): |
1248 return [] |
1248 return [] |
1249 |
1249 |
1250 def size(self): |
1250 def size(self): |