Show More
@@ -18,41 +18,7 b' from mercurial.commands import templateo' | |||
|
18 | 18 | from mercurial.i18n import _ |
|
19 | 19 | from mercurial.node import nullrev |
|
20 | 20 | from mercurial import bundlerepo, changegroup, cmdutil, commands, extensions |
|
21 | from mercurial import hg, url, util | |
|
22 | ||
|
23 | def revisions(repo, start, stop): | |
|
24 | """cset DAG generator yielding (rev, node, [parents]) tuples | |
|
25 | ||
|
26 | This generator function walks through the revision history from revision | |
|
27 | start to revision stop (which must be less than or equal to start). | |
|
28 | """ | |
|
29 | assert start >= stop | |
|
30 | cur = start | |
|
31 | while cur >= stop: | |
|
32 | ctx = repo[cur] | |
|
33 | parents = [p.rev() for p in ctx.parents() if p.rev() != nullrev] | |
|
34 | parents.sort() | |
|
35 | yield (ctx, parents) | |
|
36 | cur -= 1 | |
|
37 | ||
|
38 | def filerevs(repo, path, start, stop): | |
|
39 | """file cset DAG generator yielding (rev, node, [parents]) tuples | |
|
40 | ||
|
41 | This generator function walks through the revision history of a single | |
|
42 | file from revision start to revision stop (which must be less than or | |
|
43 | equal to start). | |
|
44 | """ | |
|
45 | assert start >= stop | |
|
46 | filerev = len(repo.file(path)) - 1 | |
|
47 | while filerev >= 0: | |
|
48 | fctx = repo.filectx(path, fileid=filerev) | |
|
49 | parents = [f.linkrev() for f in fctx.parents() if f.path() == path] | |
|
50 | parents.sort() | |
|
51 | if fctx.rev() <= start: | |
|
52 | yield (fctx, parents) | |
|
53 | if fctx.rev() <= stop: | |
|
54 | break | |
|
55 | filerev -= 1 | |
|
21 | from mercurial import hg, url, util, graphmod | |
|
56 | 22 | |
|
57 | 23 | def grapher(nodes): |
|
58 | 24 | """grapher for asciigraph on a list of nodes and their parents |
@@ -278,9 +244,9 b' def graphlog(ui, repo, path=None, **opts' | |||
|
278 | 244 | if path: |
|
279 | 245 | path = util.canonpath(repo.root, os.getcwd(), path) |
|
280 | 246 | if path: # could be reset in canonpath |
|
281 | revdag = filerevs(repo, path, start, stop) | |
|
247 | revdag = graphmod.filerevs(repo, path, start, stop) | |
|
282 | 248 | else: |
|
283 | revdag = revisions(repo, start, stop) | |
|
249 | revdag = graphmod.revisions(repo, start, stop) | |
|
284 | 250 | |
|
285 | 251 | graphdag = graphabledag(ui, repo, revdag, opts) |
|
286 | 252 | ascii(ui, grapher(graphdag)) |
@@ -8,6 +8,40 b'' | |||
|
8 | 8 | |
|
9 | 9 | from node import nullrev |
|
10 | 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 | |
|
44 | ||
|
11 | 45 | def graph(repo, start_rev, stop_rev): |
|
12 | 46 | """incremental revision grapher |
|
13 | 47 |
General Comments 0
You need to be logged in to leave comments.
Login now