Show More
@@ -183,49 +183,59 b' def walkchangerevs(ui, repo, pats, opts)' | |||||
183 | fncache[rev] = matches |
|
183 | fncache[rev] = matches | |
184 | wanted[rev] = 1 |
|
184 | wanted[rev] = 1 | |
185 |
|
185 | |||
186 | def iterate(): |
|
186 | class followfilter: | |
187 | class followfilter: |
|
187 | def __init__(self, onlyfirst=False): | |
188 | def __init__(self, onlyfirst=False): |
|
188 | self.startrev = -1 | |
189 |
|
|
189 | self.roots = [] | |
190 |
|
|
190 | self.onlyfirst = onlyfirst | |
191 | self.onlyfirst = onlyfirst |
|
191 | ||
192 |
|
192 | def match(self, rev): | ||
193 |
def |
|
193 | def realparents(rev): | |
194 | def realparents(rev): |
|
194 | if self.onlyfirst: | |
195 | if self.onlyfirst: |
|
195 | return repo.changelog.parentrevs(rev)[0:1] | |
196 | return repo.changelog.parentrevs(rev)[0:1] |
|
196 | else: | |
197 | else: |
|
197 | return filter(lambda x: x != -1, repo.changelog.parentrevs(rev)) | |
198 | return filter(lambda x: x != -1, repo.changelog.parentrevs(rev)) |
|
198 | ||
199 |
|
199 | if self.startrev == -1: | ||
200 |
|
|
200 | self.startrev = rev | |
201 |
|
|
201 | return True | |
|
202 | ||||
|
203 | if rev > self.startrev: | |||
|
204 | # forward: all descendants | |||
|
205 | if not self.roots: | |||
|
206 | self.roots.append(self.startrev) | |||
|
207 | for parent in realparents(rev): | |||
|
208 | if parent in self.roots: | |||
|
209 | self.roots.append(rev) | |||
|
210 | return True | |||
|
211 | else: | |||
|
212 | # backwards: all parents | |||
|
213 | if not self.roots: | |||
|
214 | self.roots.extend(realparents(self.startrev)) | |||
|
215 | if rev in self.roots: | |||
|
216 | self.roots.remove(rev) | |||
|
217 | self.roots.extend(realparents(rev)) | |||
202 | return True |
|
218 | return True | |
203 |
|
219 | |||
204 | if rev > self.startrev: |
|
220 | return False | |
205 | # forward: all descendants |
|
221 | ||
206 | if not self.roots: |
|
222 | # it might be worthwhile to do this in the iterator if the rev range | |
207 | self.roots.append(self.startrev) |
|
223 | # is descending and the prune args are all within that range | |
208 | for parent in realparents(rev): |
|
224 | for rev in opts.get('prune'): | |
209 | if parent in self.roots: |
|
225 | rev = repo.changelog.rev(repo.lookup(rev)) | |
210 | self.roots.append(rev) |
|
226 | ff = followfilter() | |
211 | return True |
|
227 | stop = min(revs[0], revs[-1]) | |
212 | else: |
|
228 | for x in range(rev, stop-1, -1): | |
213 | # backwards: all parents |
|
229 | if ff.match(x) and wanted.has_key(x): | |
214 | if not self.roots: |
|
230 | del wanted[x] | |
215 | self.roots.extend(realparents(self.startrev)) |
|
231 | ||
216 | if rev in self.roots: |
|
232 | def iterate(): | |
217 | self.roots.remove(rev) |
|
|||
218 | self.roots.extend(realparents(rev)) |
|
|||
219 | return True |
|
|||
220 |
|
||||
221 | return False |
|
|||
222 |
|
||||
223 | if follow and not files: |
|
233 | if follow and not files: | |
224 | ff = followfilter(onlyfirst=opts.get('follow_first')) |
|
234 | ff = followfilter(onlyfirst=opts.get('follow_first')) | |
225 | def want(rev): |
|
235 | def want(rev): | |
226 |
if rev |
|
236 | if ff.match(rev) and rev in wanted: | |
227 |
return |
|
237 | return True | |
228 |
return |
|
238 | return False | |
229 | else: |
|
239 | else: | |
230 | def want(rev): |
|
240 | def want(rev): | |
231 | return rev in wanted |
|
241 | return rev in wanted | |
@@ -2966,6 +2976,7 b' table = {' | |||||
2966 | ('', 'style', '', _('display using template map file')), |
|
2976 | ('', 'style', '', _('display using template map file')), | |
2967 | ('m', 'only-merges', None, _('show only merges')), |
|
2977 | ('m', 'only-merges', None, _('show only merges')), | |
2968 | ('p', 'patch', None, _('show patch')), |
|
2978 | ('p', 'patch', None, _('show patch')), | |
|
2979 | ('P', 'prune', [], _('do not display revision or any of its ancestors')), | |||
2969 | ('', 'template', '', _('display with template')), |
|
2980 | ('', 'template', '', _('display with template')), | |
2970 | ('I', 'include', [], _('include names matching the given patterns')), |
|
2981 | ('I', 'include', [], _('include names matching the given patterns')), | |
2971 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
|
2982 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
@@ -63,3 +63,6 b" hg ci -Amb1.1 -d'1 0'" | |||||
63 |
|
63 | |||
64 | echo % log --follow-first |
|
64 | echo % log --follow-first | |
65 | hg log --follow-first |
|
65 | hg log --follow-first | |
|
66 | ||||
|
67 | echo % log -P 2 | |||
|
68 | hg log -P 2 |
@@ -149,3 +149,29 b' user: test' | |||||
149 | date: Thu Jan 01 00:00:01 1970 +0000 |
|
149 | date: Thu Jan 01 00:00:01 1970 +0000 | |
150 | summary: base |
|
150 | summary: base | |
151 |
|
151 | |||
|
152 | % log -P 2 | |||
|
153 | changeset: 6:2404bbcab562 | |||
|
154 | tag: tip | |||
|
155 | user: test | |||
|
156 | date: Thu Jan 01 00:00:01 1970 +0000 | |||
|
157 | summary: b1.1 | |||
|
158 | ||||
|
159 | changeset: 5:302e9dd6890d | |||
|
160 | parent: 3:e62f78d544b4 | |||
|
161 | parent: 4:ddb82e70d1a1 | |||
|
162 | user: test | |||
|
163 | date: Thu Jan 01 00:00:01 1970 +0000 | |||
|
164 | summary: m12 | |||
|
165 | ||||
|
166 | changeset: 4:ddb82e70d1a1 | |||
|
167 | parent: 0:67e992f2c4f3 | |||
|
168 | user: test | |||
|
169 | date: Thu Jan 01 00:00:01 1970 +0000 | |||
|
170 | summary: b2 | |||
|
171 | ||||
|
172 | changeset: 3:e62f78d544b4 | |||
|
173 | parent: 1:3d5bf5654eda | |||
|
174 | user: test | |||
|
175 | date: Thu Jan 01 00:00:01 1970 +0000 | |||
|
176 | summary: b1 | |||
|
177 |
General Comments 0
You need to be logged in to leave comments.
Login now