Mercurial > public > mercurial-scm > hg
comparison mercurial/graphmod.py @ 8836:11ff34956ee7
graphmod/graphlog: move log walks to graphmod
author | Peter Arrenbrecht <peter.arrenbrecht@gmail.com> |
---|---|
date | Fri, 19 Jun 2009 13:14:01 +0200 |
parents | ec5483efc31f |
children | d8e3a98018cb |
comparison
equal
deleted
inserted
replaced
8835:ec5483efc31f | 8836:11ff34956ee7 |
---|---|
5 # | 5 # |
6 # This software may be used and distributed according to the terms of the | 6 # This software may be used and distributed according to the terms of the |
7 # GNU General Public License version 2, incorporated herein by reference. | 7 # GNU General Public License version 2, incorporated herein by reference. |
8 | 8 |
9 from node import nullrev | 9 from node import nullrev |
10 | |
11 def revisions(repo, start, stop): | |
12 """cset DAG generator yielding (rev, node, [parents]) tuples | |
13 | |
14 This generator function walks through the revision history from revision | |
15 start to revision stop (which must be less than or equal to start). | |
16 """ | |
17 assert start >= stop | |
18 cur = start | |
19 while cur >= stop: | |
20 ctx = repo[cur] | |
21 parents = [p.rev() for p in ctx.parents() if p.rev() != nullrev] | |
22 parents.sort() | |
23 yield (ctx, parents) | |
24 cur -= 1 | |
25 | |
26 def filerevs(repo, path, start, stop): | |
27 """file cset DAG generator yielding (rev, node, [parents]) tuples | |
28 | |
29 This generator function walks through the revision history of a single | |
30 file from revision start to revision stop (which must be less than or | |
31 equal to start). | |
32 """ | |
33 assert start >= stop | |
34 filerev = len(repo.file(path)) - 1 | |
35 while filerev >= 0: | |
36 fctx = repo.filectx(path, fileid=filerev) | |
37 parents = [f.linkrev() for f in fctx.parents() if f.path() == path] | |
38 parents.sort() | |
39 if fctx.rev() <= start: | |
40 yield (fctx, parents) | |
41 if fctx.rev() <= stop: | |
42 break | |
43 filerev -= 1 | |
10 | 44 |
11 def graph(repo, start_rev, stop_rev): | 45 def graph(repo, start_rev, stop_rev): |
12 """incremental revision grapher | 46 """incremental revision grapher |
13 | 47 |
14 This generator function walks through the revision history from | 48 This generator function walks through the revision history from |