Show More
@@ -70,7 +70,7 b' class changectx(object):' | |||||
70 | class filectx(object): |
|
70 | class filectx(object): | |
71 | """A filecontext object makes access to data related to a particular |
|
71 | """A filecontext object makes access to data related to a particular | |
72 | filerevision convenient.""" |
|
72 | filerevision convenient.""" | |
73 | def __init__(self, repo, path, changeid=None, fileid=None): |
|
73 | def __init__(self, repo, path, changeid=None, fileid=None, filelog=None): | |
74 | """changeid can be a changeset revision, node, or tag. |
|
74 | """changeid can be a changeset revision, node, or tag. | |
75 | fileid can be a file revision or node.""" |
|
75 | fileid can be a file revision or node.""" | |
76 | self._repo = repo |
|
76 | self._repo = repo | |
@@ -78,15 +78,18 b' class filectx(object):' | |||||
78 |
|
78 | |||
79 | assert changeid or fileid |
|
79 | assert changeid or fileid | |
80 |
|
80 | |||
|
81 | if filelog: | |||
|
82 | self._filelog = filelog | |||
|
83 | else: | |||
|
84 | self._filelog = self._repo.file(self._path) | |||
|
85 | ||||
81 | if not fileid: |
|
86 | if not fileid: | |
82 | # if given a changeset id, go ahead and look up the file |
|
87 | # if given a changeset id, go ahead and look up the file | |
83 | self._changeid = changeid |
|
88 | self._changeid = changeid | |
84 | self._changectx = self.changectx() |
|
89 | self._changectx = self.changectx() | |
85 | self._filelog = self._repo.file(self._path) |
|
|||
86 | self._filenode = self._changectx.filenode(self._path) |
|
90 | self._filenode = self._changectx.filenode(self._path) | |
87 | else: |
|
91 | else: | |
88 |
# else |
|
92 | # else delay changectx creation | |
89 | self._filelog = self._repo.file(self._path) |
|
|||
90 | self._filenode = self._filelog.lookup(fileid) |
|
93 | self._filenode = self._filelog.lookup(fileid) | |
91 | self._changeid = self._filelog.linkrev(self._filenode) |
|
94 | self._changeid = self._filelog.linkrev(self._filenode) | |
92 | self._filerev = self._filelog.rev(self._filenode) |
|
95 | self._filerev = self._filelog.rev(self._filenode) | |
@@ -115,17 +118,23 b' class filectx(object):' | |||||
115 | def path(self): return self._path |
|
118 | def path(self): return self._path | |
116 |
|
119 | |||
117 | def parents(self): |
|
120 | def parents(self): | |
118 | p = [ (self._path, n) for n in self._filelog.parents(self._filenode) ] |
|
121 | p = self._path | |
119 |
|
|
122 | fl = self._filelog | |
|
123 | pl = [ (p, n, fl) for n in self._filelog.parents(self._filenode) ] | |||
120 |
|
124 | |||
|
125 | r = self.renamed() | |||
121 | if r: |
|
126 | if r: | |
122 | p[0] = r |
|
127 | pl[0] = (r[0], r[1], None) | |
123 | return [ filectx(self._repo, p, fileid=n) for p,n in p if n != nullid ] |
|
128 | ||
|
129 | return [ filectx(self._repo, p, fileid=n, filelog=l) | |||
|
130 | for p,n,l in pl if n != nullid ] | |||
124 |
|
131 | |||
125 | def children(self): |
|
132 | def children(self): | |
126 | # hard for renames |
|
133 | # hard for renames | |
127 | c = self._filelog.children(self._filenode) |
|
134 | c = self._filelog.children(self._filenode) | |
128 |
return [ filectx(self._repo, self._path, fileid=x |
|
135 | return [ filectx(self._repo, self._path, fileid=x, | |
|
136 | filelog=self._filelog) for x in c ] | |||
129 |
|
137 | |||
130 | def annotate(self): |
|
138 | def annotate(self): | |
131 | return self._filelog.annotate(self._filenode) |
|
139 | return self._filelog.annotate(self._filenode) | |
|
140 |
General Comments 0
You need to be logged in to leave comments.
Login now