Mercurial > public > mercurial-scm > hg
comparison mercurial/filelog.py @ 2948:b2138d846b27
Teach annotate to follow copies.
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Fri, 18 Aug 2006 14:59:18 -0700 |
parents | db397c38005d |
children | 4ea58eb3f0c9 |
comparison
equal
deleted
inserted
replaced
2947:2d865068f72e | 2948:b2138d846b27 |
---|---|
94 for a1, a2, b1, b2 in bdiff.blocks(parent[1], child[1]): | 94 for a1, a2, b1, b2 in bdiff.blocks(parent[1], child[1]): |
95 child[0][b1:b2] = parent[0][a1:a2] | 95 child[0][b1:b2] = parent[0][a1:a2] |
96 return child | 96 return child |
97 | 97 |
98 # find all ancestors | 98 # find all ancestors |
99 needed = {node:1} | 99 needed = {(self, node):1} |
100 visit = [node] | 100 files = [self] |
101 visit = [(self, node)] | |
101 while visit: | 102 while visit: |
102 n = visit.pop(0) | 103 f, n = visit.pop(0) |
103 for p in self.parents(n): | 104 rn = f.renamed(n) |
104 if p not in needed: | 105 if rn: |
105 needed[p] = 1 | 106 f, n = rn |
106 visit.append(p) | 107 f = filelog(self.opener, f, self.defversion) |
108 files.insert(0, f) | |
109 if (f, n) not in needed: | |
110 needed[(f, n)] = 1 | |
111 else: | |
112 needed[(f, n)] += 1 | |
113 for p in f.parents(n): | |
114 if p == nullid: | |
115 continue | |
116 if (f, p) not in needed: | |
117 needed[(f, p)] = 1 | |
118 visit.append((f, p)) | |
107 else: | 119 else: |
108 # count how many times we'll use this | 120 # count how many times we'll use this |
109 needed[p] += 1 | 121 needed[(f, p)] += 1 |
110 | 122 |
111 # sort by revision which is a topological order | 123 # sort by revision (per file) which is a topological order |
112 visit = [ (self.rev(n), n) for n in needed.keys() ] | 124 visit = [] |
113 visit.sort() | 125 for f in files: |
126 fn = [(f.rev(n[1]), f, n[1]) for n in needed.keys() if n[0] == f] | |
127 fn.sort() | |
128 visit.extend(fn) | |
114 hist = {} | 129 hist = {} |
115 | 130 |
116 for r,n in visit: | 131 for i in range(len(visit)): |
117 curr = decorate(self.read(n), self.linkrev(n)) | 132 r, f, n = visit[i] |
118 for p in self.parents(n): | 133 curr = decorate(f.read(n), f.linkrev(n)) |
134 if r == -1: | |
135 continue | |
136 parents = f.parents(n) | |
137 # follow parents across renames | |
138 if r < 1 and i > 0: | |
139 j = i | |
140 while j > 0 and visit[j][1] == f: | |
141 j -= 1 | |
142 parents = (visit[j][2],) | |
143 f = visit[j][1] | |
144 else: | |
145 parents = f.parents(n) | |
146 for p in parents: | |
119 if p != nullid: | 147 if p != nullid: |
120 curr = pair(hist[p], curr) | 148 curr = pair(hist[p], curr) |
121 # trim the history of unneeded revs | 149 # trim the history of unneeded revs |
122 needed[p] -= 1 | 150 needed[(f, p)] -= 1 |
123 if not needed[p]: | 151 if not needed[(f, p)]: |
124 del hist[p] | 152 del hist[p] |
125 hist[n] = curr | 153 hist[n] = curr |
126 | 154 |
127 return zip(hist[n][0], hist[n][1].splitlines(1)) | 155 return zip(hist[n][0], hist[n][1].splitlines(1)) |